This is the mail archive of the
mailing list for the GCC project.
Re: Porting from Win C++ to linux slash vs backslash
- From: Brian Dessent <brian at dessent dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 14 Nov 2006 14:47:32 -0800
- Subject: Re: Porting from Win C++ to linux slash vs backslash
- References: <firstname.lastname@example.org>
- Reply-to: gcc-help at gcc dot gnu dot org
> Our extensive C++ library that in the past was compiled using windows has the
> following type of #include statments ...
> #include <dir1\dir2\dir3\file.h>
That's a very unfortunate choice on somebody's part. ISO C99 126.96.36.199
says that \ in the #include is undefined behavior. Furthermore,
forward-slash is a perfectly valid path separator in Windows, whereas
backslash is not a valid path separator on POSIX systems. Conclusion:
using forward slashes will work everywhere, using backslashes is
> In our example gcc will not find the file.h unless we switch the \ to / in
> the #include. We'd have to change countless files to do this.
That's a stilly excuse. You can update "countless files" in seconds
with a single command.
find . -type f -print0 | xargs -0 \
perl -pei 'm,^#\s*include, && s,\\,/,g'
(Use -i.ext if you want to keep backup copies, otherwise it will be done
in place. Use -name \*.c or whatever if you want to only match certain
> We also looked through the gcc options for an option that says to flatten
> all directories.
I seriously doubt you will find anything, given the above.