简体   繁体   English

C ++跨平台包含破折号

[英]C++ cross-platform include dash

i'm working on a little c++ cross platform project, using glfw and glew. 我正在使用glfw和glew进行一个小的c ++跨平台项目。 I wrote the original code on windows, where you include eg glfw like this 我在Windows上编写了原始代码,其中包括如下所示的glfw

#include <GLFW\glfw3.h>

When i tried to ccompile on linux it went wrong because linux uses the "/" and not the "\\" like windows, so i had to replace them all. 当我尝试在linux上进行编译时,出现了问题,因为linux使用的是“ /”而不是Windows的“ \\”,因此我不得不全部替换掉​​。 Is there a simple solution to this simple problem? 是否有解决此简单问题的简单方法?

Thanks in advance! 提前致谢!

According to the accepted answer to a similar question, just always use forward slash ( / ) for include paths. 根据对类似问题的公认答案,仅对包含路径始终使用正斜杠( / )。

This question should also help. 这个问题也应该有所帮助。

Yes, use forward slashes no matter what OS you are developing on. 是的,无论您在开发哪种操作系统,都应使用正斜杠。

Backslashes are IMHO an abomination. 反斜杠是恕我直言的可憎之物。

Also you might consider using something like CMake to build your code on both platforms. 您也可以考虑使用CMake之类的东西在两个平台上构建代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM