Solaris is complaining about the following

P

parag_paul

static char* nullStr = "null";


This line in the solaris mode64 ( cc -m64 flag, gives out the
following warning message )

"virvpirw.cc", line 371: Warning: String literal converted to char* in
initialization.
1 Warning(s) detected.



Now our builds are strict and dont allow this warning too in the
building. Can we remove this by any other way.
 
E

Eric Sosman

static char* nullStr = "null";


This line in the solaris mode64 ( cc -m64 flag, gives out the
following warning message )

"virvpirw.cc", line 371: Warning: String literal converted to char* in
initialization.
1 Warning(s) detected.



Now our builds are strict and dont allow this warning too in the
building. Can we remove this by any other way.

Two-and-a-half suggestions:

1) static const char* nullStr = "null";

2) Use a C compiler rather than a C++ compiler.

2a) ... or take further questions to comp.lang.c++
 
M

MisterE

static char* nullStr = "null";
Now our builds are strict and dont allow this warning too in the
building. Can we remove this by any other way.

static char nullStr[] = "null";
 
F

Flash Gordon

Eric Sosman wrote, On 28/09/07 13:10:
Two-and-a-half suggestions:

1) static const char* nullStr = "null";
Yes.

2) Use a C compiler rather than a C++ compiler.

2a) ... or take further questions to comp.lang.c++

cc on most versions of Unix *is* a C compiler, at least when fed a file
with a name ending in ".c". Since the warning is about a string literal
being converted to char* I see no reason to assume the OP was compiling
as C++, although I would say the warning is badly worded.
 
?

=?iso-2022-kr?q?Harald_van_D=0E=29=26=0Fk?=

Eric Sosman wrote, On 28/09/07 13:10:

cc on most versions of Unix *is* a C compiler, at least when fed a file
with a name ending in ".c".

cc on most versions of Unix is *not* a C compiler, but a C-like compiler.
Possibly, it will include options to cause it to conform to the C
standard, but typically this is not the default.
Since the warning is about a string literal
being converted to char* I see no reason to assume the OP was compiling
as C++,

Neither do I, but...
although I would say the warning is badly worded.

some not fully conforming implementations give string literals the type
const char []
rather than the unqualified version the standard requires. On those
implementations, the warning is correct. I do not know if this is the
case on this specific implementation, but it's very well possible.
 
T

Tor Rustad

Flash Gordon wrote:

[...]
cc on most versions of Unix *is* a C compiler

The Single UNIX ® Specification, Version 2:

NAME
c89 - compile standard C programs
 
I

Ian Collins

Flash said:
cc on most versions of Unix *is* a C compiler, at least when fed a file
with a name ending in ".c". Since the warning is about a string literal
being converted to char* I see no reason to assume the OP was compiling
as C++, although I would say the warning is badly worded.

In this case, Eric knows the tools. Sun CC gives this warning, which is
valid for C++.
 
E

Eric Sosman

Flash Gordon wrote On 09/28/07 16:41,:
Eric Sosman wrote, On 28/09/07 13:10:



cc on most versions of Unix *is* a C compiler, at least when fed a file
with a name ending in ".c".

Bingo.
Since the warning is about a string literal
being converted to char* I see no reason to assume the OP was compiling
as C++, although I would say the warning is badly worded.

There are two reasons to suspect the baleful presence
of That Other Language. First, the complaint is exactly
what one would expect from T.O.L., since the type it gives
a string literal is not the same as the type used by C.
Seccond, there's a cclue that may have esccaped your
noticce when you first sccanned the diagnosticc.
 
O

Old Wolf

There are two reasons to suspect the baleful presence
of That Other Language. First, the complaint is exactly
what one would expect from T.O.L., since the type it gives
a string literal is not the same as the type used by C.

The code doesn't require a diagnostic in T.O.L.
Even though string literals are const char[] in that
language, it has an implicit conversion from string
literals to char* .
 
E

Eric Sosman

Old said:
There are two reasons to suspect the baleful presence
of That Other Language. First, the complaint is exactly
what one would expect from T.O.L., since the type it gives
a string literal is not the same as the type used by C.

The code doesn't require a diagnostic in T.O.L.
Even though string literals are const char[] in that
language, it has an implicit conversion from string
literals to char* .

Yet another reason to avoid T.O.L., I'd say. If you
report truly, string literals are "ignorably const char[]."
Or, "String literals are const, and I'm shocked, shocked
to learn that you might treat them otherwise." Sounds like
a language afraid to face up to its own flaws.
 
I

Ian Collins

Eric said:
Old said:
(e-mail address removed) wrote:
static char* nullStr = "null";
"virvpirw.cc", line 371: Warning: String literal converted to
char* in
initialization.
There are two reasons to suspect the baleful presence
of That Other Language. First, the complaint is exactly
what one would expect from T.O.L., since the type it gives
a string literal is not the same as the type used by C.

The code doesn't require a diagnostic in T.O.L.
Even though string literals are const char[] in that
language, it has an implicit conversion from string
literals to char* .

Yet another reason to avoid T.O.L., I'd say. If you
report truly, string literals are "ignorably const char[]."
Or, "String literals are const, and I'm shocked, shocked
to learn that you might treat them otherwise." Sounds like
a language afraid to face up to its own flaws.
Or one weighed down by the flaws of its parent :)
 
W

Wade Ward

and rodney king have the same IQ."
Ian Collins said:
Eric said:
Old said:
(e-mail address removed) wrote:
static char* nullStr = "null";
"virvpirw.cc", line 371: Warning: String literal converted to
char* in
initialization.
There are two reasons to suspect the baleful presence
of That Other Language. First, the complaint is exactly
what one would expect from T.O.L., since the type it gives
a string literal is not the same as the type used by C.

The code doesn't require a diagnostic in T.O.L.
Even though string literals are const char[] in that
language, it has an implicit conversion from string
literals to char* .

Yet another reason to avoid T.O.L., I'd say. If you
report truly, string literals are "ignorably const char[]."
Or, "String literals are const, and I'm shocked, shocked
to learn that you might treat them otherwise." Sounds like
a language afraid to face up to its own flaws.
Or one weighed down by the flaws of its parent :)
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top