Min*_*aik 15 c++ linux windows mkdir
将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
Run Code Online (Sandbox Code Playgroud)
任何想法我能做什么,以便它适用于两个系统?
gco*_*ard 29
#if defined(_WIN32)
_mkdir(strPath.c_str());
#else
mkdir(strPath.c_str(), 0777); // notice that 777 is different than 0777
#endif
Run Code Online (Sandbox Code Playgroud)