Date: Mon, 11 May 1998 17:30:15 +0300 (IDT) From: Eli Zaretskii To: Andris Pavenis cc: "Gurunandan R. Bhat" , djgpp AT delorie DOT com Subject: Re: / and \ in gcc2.8.1 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 11 May 1998, Andris Pavenis wrote: > There were some problems when I defined DIR_SEPARATOR in gcc configuration > as many programs expect to get '/' in dependencies (for example RHIDE). Is DIR_SEPARATOR new with version 2.8.x? If not, how did GCC 2.7.x solve this problem? > Unfortunatelly looks that the only correct way is to define DIR_SEPARATOR > in config/xm-go32.h. I hoped to avoid this. > > There is more problems: > 'gcc -M -c foo/bar.c' outputs 'bar.o: foo/bar.c ...' > 'gcc -M -c foo\bar.c' outputs 'foo\bar.o: foo\bar.c ...' Sigh... Been there, done that. In general, there are two ways to handle such nuisances: 1) Find out all the places where the sources reference '/' or "/" and change them all to a macro call. For example, if the original sources say something like this: if (c == '/') then change it to this: if (IS_SLASH (c)) and define IS_SLASH on some system header like this: #ifdef DOSISH # define IS_SLASH(c) ((c) == '/' || (c) == '\\') #else # define IS_SLASH(c) ((c) == '/') #endif (Here DOSISH should be defined for MSDOS, WIN32 and other systems which use backslashes.) 2) The other way is to convert all the file name arguments to the Unix-style forward slashes *before* they get into the processing parts of the program, and live happily ever after. The first way is usually better (since you get support for both styles, and file names are printed back in the same form as the user typed them), but it requires to find and change individually all these places. (You can use `fgrep' to find them, but editing can be a pain unless you use a good editor with global substitution feature.) Also, be aware that sometimes the above is not enough, as on Unix a code that says if (*filename == '/') actually intends to test whether the file name is absolute or relative, so on DOSISH systems you need to introduce yet another macro IS_ABSOLUTE which looks for drive letters. The second way is much easier, but it's only possible if you can identify a small number of places where all file names are seen first, before they are processed. If programs such as RHIDE expect output from GCC to be always with forward slashes, it seems like the second way is a better alternative, if it is practical. > There is still one question whether there is possible to get backslashes > converted to normal slashes when outputing dependencies (for modified > version of mktemp there is no problem to do this) to have for example > c:/djgpp/include/stdio.h in dependencies instead of c:\djgpp\include\stdio.h This should be a fallback solution, in case that the second way above is impossible. > Yes it looks for TMP and TEMP if previous ones is not found. Then fixing this specific problem is even more important, as TEMP is set by DOS and Windows by default, and of course with backslashes.