cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/09/07/10:28:08

Message-Id: <199809071523.RAA36830@ieva06.lanet.lv>
From: "Andris Pavenis" <pavenis AT lanet DOT lv>
To: djgpp-workers AT delorie DOT com
Date: Mon, 7 Sep 1998 17:27:53 +0300
MIME-Version: 1.0
Subject: Problem with DJLSR202 and EGCS-1.1

Hi!

There is one problem building DJLSR202 with egcs-1.1 (I think there is the same 
problem also with 2.01):
 
If the compiler option -Wcast-qual is specified egcs-1.1 issues warning when casting 
some pointer types (previous versions failed to do this, as I think warning is correct). 
I'm giving and example that ilustrates this problem:

#include <stdio.h>

void foo ( const char * const * );

int  main (int argc, char ** argv)
  {
      const char * t1 = *argv;
      char * const * t2= (char * const *) & t1;
      //        Construction used in djlsr. Gives warning:
      //        cast discards `const' from pointer target type
      const char * const * t3 = argv;
      //        Gives error:
      //        initialization from incompatible pointer type
      foo (argv);
      //        Gives error:
      //        passing arg 1 of `foo' from incompatible pointer type
      return 0;
  }

The first fix I tried was to replacing 'char * const *'  by 'const char * const *' but it
cannot be solution of problem as all gcc versions I tested refuses cast from
'char **' to 'const char * const *' in procedure parameters unless I'm specifying 
it explicitly. Therefore we should not use 'const char * const *' in include files as 
such type requires explicit cast from 'char **'

So looks that only one solution remains: converting the type using unions that
already were used in djlsr. (Of course if we don't want to remove options 
-Wcast-qual and(or) -Werror). And let's hope that future versions of gcc will not
catch such attempts to fool gcc using unions.

Andris

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019