Mac and Windows difference header path (/ vs \)

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?

Answers


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! :)


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) :

If the characters ', \, ", //, or /* occur in the sequence between the < and > delimiters, the behavior is undefined. Similarly, if the characters ', \, //, or /* occur in the sequence between the " delimiters, the behavior is undefined.

Although some compilers may accept \ in an include path, they are all required to accept /.


Need Your Help

Check text area for URLs with preg_match

preg-match ereg

i found this code for checking a text area:

ANTLR rule to skip method body

c# antlr rule skip

My task is to create ANTLR grammar, to analyse C# source code files and generate class hierarchy. Then, I will use it to generate class diagram.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.