我正在将一些软件从 Unix 移植到 Window,并在 Windows XP SP3 上使用 g++ v4.7。我有一个如下所示的头文件声明:
#include <string>
#include <sys/types.h>
using namespace std;
bool MakeDir(const string &dirName,
mode_t mode =S_IRWXU | S_IRWXG | S_IRWXO);
但是当我编译它时,我收到此错误:
FileName.h:35:40: error: 'S_IRWXG' was not declared in this scope
FileName.h:35:50: error: 'S_IRWXO' was not declared in this scope
为什么 sys/types.h
会定义 S_IRWXU
而不是 S_IRWXG
或 S_IRWXO
?
我发现了一些在 Windows 上定义它们的代码,如下所示:
#define S_IRWXG (S_IRWXU >> 3)
#define S_IRWXO (S_IRWXG >> 3)
这看起来像是一个拼凑并且容易破坏,是否有更好的方法来获取这些定义?我不想使用 Cygwin。
最佳答案
S_IRWXG 和 S_IRWXO 适用于 Linux,在 Windows 上您不需要它们, 您可以从 Linux 获得的值
关于c++ - 为什么 Windows 上的 sys/types.h 中没有定义 S_IRWXG 和 S_IRWXO?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13575543/