Search code examples
clinuxmacrosposixflags

How to include only definitions from header


I'm implementing right now some syscalls from unistd.h and fcntl.h (open, read, close, e.t.c) Some of the require special flags and macros (O_CREAT, O_RDWR)

Is there a way to include only the flags and macros without the function definitions from unistd.h and fcntl.h?

Thanks


Solution

  • Perhaps the -imacros option to gcc is what you are looking for.

    -imacros FILE

     Exactly like `-include`, except that any output produced by
     scanning FILE is thrown away.  Macros it defines remain defined.
     This allows you to acquire all the macros from a header without
     also processing its declarations.