包括从 Windows 到 Linux 的标头路径更改

2022-01-11 00:00:00 header include c++ backslash

我正在将一个用 C++ 编写的应用程序从 Windows 移植到 Linux.我的头文件路径有问题.Windows 使用 ,Linux 使用 /.我发现在每个源文件和头文件中更改它很麻烦.有什么解决办法吗?

I'm porting an application written in C++ from Windows to Linux. I have a problem with the header files path. Windows uses and Linux uses /. I am finding it cumbersome to change this in each and every source and header file. Is there some work around?

推荐答案

在#include 路径中始终使用正斜杠.将路径映射到底层操作系统支持的任何斜线/目录方案是编译器的工作.

Always use forward slashes in #include paths. It is the compiler's job to map the path to whatever slash/directory scheme the underlying OS supports.

相关文章