0
votes

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

2
If it's only for a test, you could edit the 2 files and surround the function prototypes by #ifdef DONT_INCLUDE_PROTOTYPES ... #endif. - ott--
I don't want to edit the header files. Is there any other way? - Jah
What is the motivation for this? - robert
You could copy the files to myunistd.h and myfcntl.h in your source-dir and then include them with #include "myunistd.h" after editing. Can you explain, what you're trying to do at all? - ott--

2 Answers

1
votes

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.
0
votes

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.