Mac 和 Windows 头文件路径差异(/ 与 \)
我有一个也可以在 XCode 上运行的 Windows 项目。但我必须更改所有源标头路径,例如
#include "Adapter\EngineAdapterFactory.hpp"
,
#include "Adapter/EngineAdapterFactory.hpp"
这非常烦人,我稍后可能必须反转 Visual Studio 的过程。其他人如何解决这个问题?
I have a Windows project that also works on XCode. But I had to changed all the source header paths like
#include "Adapter\EngineAdapterFactory.hpp"
to
#include "Adapter/EngineAdapterFactory.hpp"
This is quite annoying and I might have to reverse the process for Visual Studio later. How can others solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够在两个平台上使用
Adapter/EngineAdapterFactory.hpp
。(至少 Windows 上的 GCC 是这样。)
实际上,这不仅仅是编译器的特征 - 即使使用 Windows 资源管理器,您也应该能够使用
/
作为目录分隔符进行导航。打开资源管理器并在地址栏中插入类似以下内容的内容:c:/Some/Folder/Structure
。应该可以完美地工作,除非你使用的是非常旧的 Windows 版本(我可以确认它可以在 XP 及更高版本上工作,但可能它的存在时间更长)。感谢微软的兼容! :)You should be able to use
Adapter/EngineAdapterFactory.hpp
on both platforms.(At least that's the case with GCC on Windows.)
Actually, that's not just the trait of compilers - even with Windows Explorer you should be able to navigate with
/
as directory separator. Open up Explorer and insert in your address bar something like:c:/Some/Folder/Structure
. Should work flawlessly unless you're on a really old Windows version (I can confirm it working on XP and up, but probably it's there even longer). Thanks, Microsoft, for being compatible! :)您不应该在包含路径中使用
\
,这不是平台问题而是语言问题(C99 标准中的 6.4.7/3):尽管某些编译器可能接受包含路径中的
\
,但它们都要求接受/
。You should never use
\
in a include path, and its not a matter of platform but language (6.4.7/3 from the C99 standard) :Although some compilers may accept
\
in an include path, they are all required to accept/
.