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

Started by
5 comments, last by Emmanuel Deloget 17 years, 11 months ago
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.

Steven Yau
[Blog] [Portfolio]

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

All C preprocessors understand forward slashes, even on platforms that use a backslash or a colon as the path separator.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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.
I agree with the statements presented thus far in the thread.
I disagree completely!









Just kidding, I agree.
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,

This topic is closed to new replies.

Advertisement