0

我现在正在实现来自 unistd.h 和 fcntl.h 的一些系统调用(打开、读取、关闭等) 一些需要特殊标志和宏(O_CREAT、O_RDWR)

有没有办法只包含标志和宏而没有来自 unistd.h 和 fcntl.h 的函数定义?

谢谢

4

2 回答 2

1

也许-imacros选项gcc就是您正在寻找的。

-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.
于 2012-07-02T12:55:00.283 回答
0

一般来说 - 没有。如果您查看有问题的标题,您会发现没有原型被明确的宏包围,这只会排除它们。

您可能会设法通过包括 sys/types.h、stddef.h 等来获得一些定义,但不是全部。

所有的函数原型都被声明为“extern”,顺便说一句,因此应该不会成为您实现的障碍。

于 2012-07-02T12:07:48.087 回答