Jump to content
  • Advertisement
Sign in to follow this  
yaustar

#include file paths. '/' or '\'?

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am going to have to ask this since this has been bugging me to no end. Which slash should be used to include files? '../foo.h' or '..\foo.h'? Does it matter which one I use and if it does, please list the reasons why. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You should use forward slash I think. This will work across compilers platforms (Linux, Windows etc.) whereas a backward slash only works on Windows.

* This may be completly wrong, I just remember reading it at some point. * :)

Share this post


Link to post
Share on other sites
All C preprocessors understand forward slashes, even on platforms that use a backslash or a colon as the path separator.

Share this post


Link to post
Share on other sites
Quote:
Original post by yaustar
I am going to have to ask this since this has been bugging me to no end. Which slash should be used to include files? '../foo.h' or '..\foo.h'? Does it matter which one I use and if it does, please list the reasons why.

Thanks.


Reiterating what Fruny said ... always use "/" because it is correct on any platform.

Share this post


Link to post
Share on other sites
Yup. I'd like to add this quote from the Holy One, section 2.8 (Header names) §2:
Quote:

If either of the characters ' or \, or either of the character sequences /* or // appears in a q-char-sequence or a h-char-sequence, or the character " appears in a h-char-sequence, the behavior is undefined.

So yes, prefer / since it is guaranteed to work.

Regards,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!