Re: RE:[bv@bnl.gov: [ROOT] Method(const char*&

From: Brett Viren (bv@bnl.gov)
Date: Wed Mar 07 2001 - 19:48:02 MET


Masaharu Goto writes:
 > 
 > I tried your example in LinuxRH6.2 and Windows-ME VC++6.0 and it 
 > was compiled without problem in both environment. I understand
 > what you are trying to point out. However, may be because of different
 > g++ version, I can not reproduce the problem. Will you give me following
 > information?
 > 
 >  - Version of g++

g++ -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)

 >  - What change to following line make your compiler happy? Because I can
 >   not reproduce it, I need this information from you. Do I need to cast
 >   like (const char**) or (char *const*)? Or something else?
 >     ((const 
 > blah*)(G__getstructoffset()))->Get(libp->para[0].ref?*(char**)libp->para[0].re
 > f
 > :*(char**)(&G__Mlong(libp->para[0])));
 > 

What ever gets passed to the ``Get(const char*&)'' method must be a
`const char*&' so the following is what is needed:

 ((const blah*)(G__getstructoffset()))->Get(libp->para[0].ref?*(const char**)libp->para[0].ref:*(const char**)(&G__Mlong(libp->para[0])));


So, yes, the casts should be to `const char**' and not just `char **'.
I tested this by changing the generated file and recompiling and it
indeed works.

The default version of gcc (egcs 1.1.2 aka gcc 2.91) on Red Hat 6.2 is
known to be much more relaxed when encountering const problems which
the ``newer'' gcc 2.95.2 catch and consider errors.  This is why you
find no problem with compiling my sample code on RH 6.2.  Windows-ME
VC++ 6.0 must also be relaxed about const errors.

Thanks,
-Brett.



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:39 MET