Skip to content

Build Fails on Musl LibC #57

@oneechanhax

Description

@oneechanhax

It appears to conflict with defines from the libc.

/ocvm.reproduce$ make lua=lua5.3 CXX=clang 
clang  -I/usr/include/lua5.3 -MMD -MP -Wall -g --std=c++17 -O0 -Wl,--no-as-needed -I. -Iapis -Icolor -Icomponents -Idrivers -Iio -Imodel -Iutil -c drivers/internet_http.cpp -o bin/drivers/internet_http.cpp.o
clang: warning: -Wl,--no-as-needed: 'linker' input unused [-Wunused-command-line-argument]
drivers/internet_http.cpp:129:27: error: expected unqualified-id
  129 | Connection* PipedCommand::stdin() const
      |                           ^
drivers/internet_http.cpp:134:27: error: expected unqualified-id
  134 | Connection* PipedCommand::stdout() const
      |                           ^
drivers/internet_http.cpp:139:27: error: expected unqualified-id
  139 | Connection* PipedCommand::stderr() const
      |                           ^
drivers/internet_http.cpp:197:29: error: expected unqualified-id
  197 |     Connection* resp = _cmd.stderr();
      |                             ^
/usr/include/stdio.h:68:16: note: expanded from macro 'stderr'
   68 | #define stderr (stderr)
      |                ^
drivers/internet_http.cpp:282:15: error: expected unqualified-id
  282 |   return _cmd.stdout();
      |               ^
/usr/include/stdio.h:67:16: note: expanded from macro 'stdout'
   67 | #define stdout (stdout)
      |                ^
5 errors generated.
make: *** [Makefile:46: bin/drivers/internet_http.cpp.o] Error 1

Easy dumb way to fix it and make it compile for me.

#undef stdin

Connection* PipedCommand::stdin() const
{
  return _stdin.get();
}

#undef stdout
Connection* PipedCommand::stdout() const
{
  return _stdout.get();
}

#undef stderr
Connection* PipedCommand::stderr() const
{
  return _stderr.get();
}

A better way to do this is to do it conditionally.
If the system is linux, but not GNU libc.

Unsure about the other variants of libc and if they define these the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions