Jah
Jah

Reputation: 1039

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

Upvotes: 0

Views: 97

Answers (2)

MvG
MvG

Reputation: 60958

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.

Upvotes: 1

fork0
fork0

Reputation: 3459

Generally - no. If you look at the headers in question, you'll see that no prototypes are surrounded by definitive macroses, which will just exclude them.

You might manage to get some of the definitions by including sys/types.h, stddef.h and the like, but not all of them.

All the function prototypes are declared "extern", BTW, and as such should be no obstacle to your implementation.

Upvotes: 0

Related Questions