Home > Blockchain >  fatal error: 'sys/sysmacros.h' file not found
fatal error: 'sys/sysmacros.h' file not found

Time:11-02

I have a compilation error on macOS Big Sur with the standard clang compiler (version 13.0.0).

I am trying to include the sys/sysmacros.h to use the makedev() function which suprisingly is mentioned on the apple developer website and should be compatible with macOS 15.5

Including sys/types.h also gives me an error, however sys/stat.h works. Sadly it still doesn't give me the makedev(), major() and minor() functions that I need.

The linux manual page of makedev states there were some changes in the glibc library but as far as I know macOS does not use the glibc library. There should be a simple way of installing glibc on macOS using brew as described here but I get the same error as was mentioned in this thread. So apparently currently there is no proper way of doing it and then I am not sure if this will solve my problem.

Does anybody know a solution to this? Or is there someone who encountered a similar problem?

CodePudding user response:

This macro makedev is defined in sys/types.h. Just add #include <sys/types.h> into your files. sys/types.h is a header file of Kernel.framework. You should set it in clang invocation like clang -framework Kernel ....

You also can define these macros as they are defined in sys/types.h:

#define major(x)        ((int32_t)(((u_int32_t)(x) >> 24) & 0xff))
#define minor(x)        ((int32_t)((x) & 0xffffff))
#define makedev(x, y)    ((dev_t)(((x) << 24) | (y)))
  • Related