Patch for new gnu compiler warning: deprecated conversion from string constant to 'char*'

Raphael Collet raphael.collet at uclouvain.be
Sun Apr 27 18:05:21 CEST 2008


Kevin Glynn wrote:
> 
> The problem is the linker.  Try it with the attached files.
> 
>    @twiglet:tmp 4Q> g++ -c mozart.cc
>    @twiglet:tmp 4Q> g++ -c hello.cc
>    hello.cc: In function ?int main()?:
>    hello.cc:6: warning: deprecated conversion from string constant to ?char*?
>    @twiglet:tmp 4Q> g++ -o hello mozart.o hello.o
>    @twiglet:tmp 4Q> ./hello
> 
> Now change the signature of myout in mozart.hh and mozart.cc to be
> const char * and try:
> 
>    @twiglet:tmp 4Q> vi mozart.hh
>    @twiglet:tmp 4Q> vi mozart.cc
>    @twiglet:tmp 4Q> g++ -c mozart.cc
>    @twiglet:tmp 4Q> g++ -o hello mozart.o hello.o
>    hello.o: In function `main':
>    hello.cc:(.text+0x192): undefined reference to `myout(char*)'
>    collect2: ld returned 1 exit status
>    (1)@twiglet:tmp 4Q> 
> 
> oh dear,  that was the reason for my shame comment above.

Okay, now I got it!  The compiled symbol is different, damned.

I have another proposal, then.  Let's use a macro to introduce the 
"const" modifier in the functions OZ_mkTupleC, etc.  The declarations 
will look like:

_FUNDECL(OZ_Term  ,OZ_mkTupleC,(CONST42 char *label,int arity,...));

with CONST42 defined as:

// define DONTUSECONST42 if the linker complains
#ifndef DONTUSECONST42
#define CONST42 const
#else
#define CONST42
#endif

People should be encouraged to recompile their stuff.  And maybe we can 
provide a specific package for those who have linking issues and cannot 
recompile their stuff...


Cheers,
raph



More information about the mozart-hackers mailing list