Date: Wed, 9 Sep 1998 17:55:19 +0200 (WET) From: Andris Pavenis To: DJ Delorie cc: djgpp-workers AT delorie DOT com Subject: Re: Updated diffs for compiling DJLSR-980907 with EGCS-1.1 In-Reply-To: <199809091316.JAA19165@delorie.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Wed, 9 Sep 1998, DJ Delorie wrote: > > OK, the real question is - why do we need to remove the const-ness? > There's no reason why those functions need to change those parameters, > so why can't they accept the const parameters? > Unfortunatelly egcs-1.1 gives warning in cast: const char * foo; (char * const *) & foo; when gcc option -Wcast-qual is specified. It compiles Ok with both gcc-2.7.2.1 and gcc-2.8.1 but not with egcs-1.1. I think that compiler is right as 'char * const *' is constant pointer to string, so cast removes const and of course compiler should issue warning (when -Wcast-qual is specified). Specifying 'const char * const *' in parameters is not a solution for global function as then we are not able to specify variable with type char ** as a parameter (what would ve very annoying). Here is an example that ilustrates this (compiled under Linux, but I'm getting the same with DJGPP) ----------------------------------------- hal:~/tmp# cat xx.c int foo1 (const char * const *); int foo2 (char * const *); int bar (const char * xx , char * yy) { foo1 (&xx); foo2 (&xx); foo2 ((char * const *) & xx); foo1 (&yy); foo2 (&yy); return 0; } ----------------------------------------- hal:~/tmp# gcc -c -Wcast-qual xx.c xx.c: In function `bar': xx.c:6: warning: passing arg 1 of `foo2' from incompatible pointer type xx.c:7: warning: cast discards `const' from pointer target type xx.c:8: warning: passing arg 1 of `foo1' from incompatible pointer type hal:~/tmp# ----------------------------------------- One more thing. Tried to build DJLSR using cross-compiler under Linux (the same version: egcs-1.1). Some problems I met: - native libc.a include files (libc-5.4.46) defines POSIX_SOURCE that effectively eliminates contents of coff.h from djcrx202.zip; - I used binutils 2.9.1.0.10 (same source archive as I'm using under Linux). There were some changes in i86 assembler and I had to modify some sources in src/ansi/math. I checked that after these changes sources still compiles also under DOS. Looks that crossbuilding DJLSR under Linux is much more faster than native one. I haven't checked results yet so let's see what I have got. Perhaps I'll include examples of scripts for building cross to DJGPP compiler with next update of egcs-1.1 sources. Andris