这是我第一次使用posix;我已经包含了:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
我有一个代码片段。
而且我有这个片段。
stat(pathname, &sb);
if ((sb.st_mode & S_IFMT) == S_IFREG) {
/* Handle regular file */
}
但是,在 Gentoo 上使用 GCC 4.8.3 编译时,如果我使用 -std=c99、-std=c11 或 -std=gnu99、-std=gnu11 这些选项进行编译,就会出现以下错误:
error: ‘S_ISFMT’ undeclared (first use in this function)
如果我省略 -std=*,就不会出现错误。但我也想要 -std=c99 的所有功能(如关键字 restrict 或 for(int i;;) 等等...)。我该如何编译我的代码?