Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Solaris is complaining about the following (http://www.velocityreviews.com/forums/t540580-solaris-is-complaining-about-the-following.html)

parag_paul@hotmail.com 09-28-2007 10:18 AM

Solaris is complaining about the following
 
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.


Eric Sosman 09-28-2007 12:10 PM

Re: Solaris is complaining about the following
 
parag_paul@hotmail.com wrote:
> 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++

--
Eric Sosman
esosman@ieee-dot-org.invalid

MisterE 09-28-2007 12:56 PM

Re: Solaris is complaining about the following
 

<parag_paul@hotmail.com> wrote in message
news:1190974734.536122.184670@50g2000hsm.googlegro ups.com...
> 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";


Flash Gordon 09-28-2007 08:41 PM

Re: Solaris is complaining about the following
 
Eric Sosman wrote, On 28/09/07 13:10:
> parag_paul@hotmail.com wrote:
>> 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";


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.
--
Flash Gordon

=?iso-2022-kr?q?Harald_van_D=0E=29=26=0Fk?= 09-28-2007 09:12 PM

Re: Solaris is complaining about the following
 
On Fri, 28 Sep 2007 21:41:05 +0100, Flash Gordon wrote:
> Eric Sosman wrote, On 28/09/07 13:10:
>> parag_paul@hotmail.com wrote:
>>> 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";

>
> 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".


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.

Tor Rustad 09-28-2007 09:58 PM

Re: Solaris is complaining about the following
 
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

--
Tor <torust [at] online [dot] no>
"I have stopped reading Stephen King novels. Now I just read C code instead"

Ian Collins 09-28-2007 09:59 PM

Re: Solaris is complaining about the following
 
Flash Gordon wrote:
>
> 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++.

--
Ian Collins.

Eric Sosman 09-28-2007 10:31 PM

Re: Solaris is complaining about the following
 
Flash Gordon wrote On 09/28/07 16:41,:
> Eric Sosman wrote, On 28/09/07 13:10:
>
>>parag_paul@hotmail.com wrote:
>>
>>> 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";

>
>
> 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".


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.

--
Eric.Sosman@sun.com

Dik T. Winter 09-29-2007 01:30 AM

Re: Solaris is complaining about the following
 
In article <1g50t4x81b.ln2@news.flash-gordon.me.uk> Flash Gordon <spam@flash-gordon.me.uk> writes:
....
> >> "virvpirw.cc", line 371: Warning: String literal converted to char* in

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


But is that the case here?
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

Flash Gordon 09-29-2007 11:26 AM

Re: Solaris is complaining about the following
 
Eric Sosman wrote, On 28/09/07 23:31:
> Flash Gordon wrote On 09/28/07 16:41,:
>> Eric Sosman wrote, On 28/09/07 13:10:
>>
>>> parag_paul@hotmail.com wrote:


<snip>

>>>> "virvpirw.cc", line 371: Warning: String literal converted to char* in


<snip>

>> 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.


<snip>

> Seccond, there's a cclue that may have esccaped your
> noticce when you first sccanned the diagnosticc.


Yes, I did miss that. You were correct.
--
Flash Gordon


All times are GMT. The time now is 03:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.