E
Eric
I am working on a large, old code base and attempting to move it to
GCC 4.2. Throughout the code, there is stuff like:
char *aVar = "aString";
or
void aFunc( char *aVar) { ... }
aFunc( "aString" );
With this latest version of GCC, such code now generates the warning:
warning: deprecated conversion from string constant to 'char*'
and since I hate warnings, I am wondering what the best way to handle
this situation is.
There are, of course, some warnings which can safely be disabled and
ignored...is this one of them?
It doesn't seem to be based on the fact that it is 'deprecated' which
I interpret as meaning the ability to do this in the future will go
away.
Now, I can get rid of the warning by placing a (char*) in front of the
string (but not (const char*)...why?).
I can also get rid of the warning by changing the code to look like:
const char *aVar = "aString";
void aFunc( const char *aVar) { ... }
which seems to be a better solution.
Any thoughts, comments or suggestions?
GCC 4.2. Throughout the code, there is stuff like:
char *aVar = "aString";
or
void aFunc( char *aVar) { ... }
aFunc( "aString" );
With this latest version of GCC, such code now generates the warning:
warning: deprecated conversion from string constant to 'char*'
and since I hate warnings, I am wondering what the best way to handle
this situation is.
There are, of course, some warnings which can safely be disabled and
ignored...is this one of them?
It doesn't seem to be based on the fact that it is 'deprecated' which
I interpret as meaning the ability to do this in the future will go
away.
Now, I can get rid of the warning by placing a (char*) in front of the
string (but not (const char*)...why?).
I can also get rid of the warning by changing the code to look like:
const char *aVar = "aString";
void aFunc( const char *aVar) { ... }
which seems to be a better solution.
Any thoughts, comments or suggestions?