加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – mkdir Windows与Linux

发布时间:2020-12-16 05:32:13 所属栏目:百科 来源:网络整理
导读:将 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 Window
将 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读