Sign in to follow this  
yaustar

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this