【发布时间】:2011-10-23 01:13:15
【问题描述】:
我刚刚在 Visual Studio (Windows) 中打开了我的一个旧项目,添加了目录 test 并发现了编译错误。 我刚刚从我的其他工作项目中复制了该函数并添加了相同的标题。 如果你点击 F12 stats.h 被打开并且你得到了标识符但不知何故编译器看不到它?
#include <sys/types.h>
#include <sys/stat.h>
void my_function()
{
...
struct _stat buf;
_wstat(dir, &buf);
if ((buf.st_mode & _S_IFDIR) > 0) { // here _S_IFDIR undefined
...
}
}
【问题讨论】:
-
请用相关系统标记。对于 Unix,
stat和S_IFDIR的开头没有下划线,也没有_wstat。 -
是的,stat.h。我在 Windows 中使用 Visual Studio。 S_IFDIR 也在 stat.h 中声明为 _S_IFDIR