我在将 Linux 工具移植到 Windows 时遇到问题。我在 Windows 系统上使用 MinGW。我有一个处理所有输入/输出的类,其中包括这一行:
mkdir(strPath.c_str(), 0777); // works on Linux but not on Windows and when it is changed to
_mkdir(strPath.c_str()); // it works on Windows but not on Linux
任何想法我可以做什么,以便它在两个系统上都适用?
最佳答案
#if defined(_WIN32)
_mkdir(strPath.c_str());
#else
mkdir(strPath.c_str(), 0777); // notice that 777 is different than 0777
#endif
关于c++ - mkdir Windows 与 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10356712/