Skip to content

Conflict with unistd.h on Mac OS  #1046

@DavisVaughan

Description

@DavisVaughan

CC @kevinushey who has also been helping me with this

Minimum package to reproduce issue:
https://github.com/DavisVaughan/testunistd

If I am on the dev version of Rcpp, 1.0.4, then I cannot compile the package linked above. It includes this header declaration ordering:

// Works on 1.0.3
// Fails on github 1.0.4
#include <Rcpp.h>
#include <unistd.h>
  • If I use 1.0.3, it works as is
  • If I reverse the include ordering while on 1.0.4, it works

I am on Mac OS 10.14.5

This is the error that I get, it looks like some conflict with the sys/_types/_uuid_t.h file in the mac SDK, but I haven't been able to track it down any further than this.

> devtools::load_all(".")
Loading testunistd
Re-compiling testunistd
─  installing *source* package ‘testunistd’ ...
   ** using staged installation
   ** libs
   clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c code.cpp -o code.o
   In file included from code.cpp:4:
   In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:658:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/gethostuuid.h:39:17: error: C++ requires a type specifier for all declarations
   int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
                   ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:665:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      getsgroups_np(int *, uuid_t);
                                 ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:667:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      getwgroups_np(int *, uuid_t);
                                 ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:730:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      setsgroups_np(int, const uuid_t);
                                     ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:732:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      setwgroups_np(int, const uuid_t);
                                     ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   5 errors generated.
   make: *** [code.o] Error 1
   ERROR: compilation failed for package ‘testunistd’
─  removing ‘/private/var/folders/41/qx_9ygp112nfysdfgxcssgwc0000gn/T/Rtmp62mMQq/devtools_install_11e537e56fd61/testunistd’
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:732:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
E> int      setwgroups_np(int, const uuid_t);
E>                                   ^
E> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
E> typedef __darwin_uid_t        uid_t;
E>                               ^
E> 5 errors generated.
E> make: *** [code.o] Error 1
E> ERROR: compilation failed for package ‘testunistd’
E> * removing ‘/private/var/folders/41/qx_9ygp112nfysdfgxcssgwc0000gn/T/Rtmp62mMQq/devtools_install_11e537e56fd61/testunistd’
Type .Last.error.trace to see where the error occured

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions