Solaris is complaining about the following

Discussion in 'C Programming' started by parag_paul@hotmail.com, Sep 28, 2007.

  1. Guest

    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.
    , Sep 28, 2007
    #1
    1. Advertising

  2. Eric Sosman Guest

    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
    lid
    Eric Sosman, Sep 28, 2007
    #2
    1. Advertising

  3. MisterE Guest

    <> wrote in message
    news:...
    > 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";
    MisterE, Sep 28, 2007
    #3
  4. Flash Gordon Guest

    Eric Sosman wrote, On 28/09/07 13:10:
    > 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
    Flash Gordon, Sep 28, 2007
    #4
  5. On Fri, 28 Sep 2007 21:41:05 +0100, Flash Gordon wrote:
    > Eric Sosman wrote, On 28/09/07 13:10:
    >> 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.
    =?iso-2022-kr?q?Harald_van_D=0E=29=26=0Fk?=, Sep 28, 2007
    #5
  6. Tor Rustad Guest

    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"
    Tor Rustad, Sep 28, 2007
    #6
  7. Ian Collins Guest

    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.
    Ian Collins, Sep 28, 2007
    #7
  8. Eric Sosman Guest

    Flash Gordon wrote On 09/28/07 16:41,:
    > Eric Sosman wrote, On 28/09/07 13:10:
    >
    >> 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, Sep 28, 2007
    #8
  9. In article <-gordon.me.uk> Flash Gordon <> 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/
    Dik T. Winter, Sep 29, 2007
    #9
  10. Flash Gordon Guest

    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:
    >>
    >>> 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
    Flash Gordon, Sep 29, 2007
    #10
  11. Old Wolf Guest

    On Sep 29, 10:31 am, Eric Sosman <> wrote:
    >
    > >> 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* .
    Old Wolf, Oct 2, 2007
    #11
  12. Eric Sosman Guest

    Old Wolf wrote:
    > On Sep 29, 10:31 am, Eric Sosman <> wrote:
    >>>> 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.

    --
    Eric Sosman
    lid
    Eric Sosman, Oct 2, 2007
    #12
  13. Ian Collins Guest

    Eric Sosman wrote:
    > Old Wolf wrote:
    >> On Sep 29, 10:31 am, Eric Sosman <> wrote:
    >>>>> 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 :)

    --
    Ian Collins.
    Ian Collins, Oct 2, 2007
    #13
  14. Wade Ward Guest

    and rodney king have the same IQ."
    "Ian Collins" <> wrote in message
    news:...
    > Eric Sosman wrote:
    >> Old Wolf wrote:
    >>> On Sep 29, 10:31 am, Eric Sosman <> wrote:
    >>>>>> 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 :)

    :)
    --
    wade ward
    "The final irony is that cops
    Wade Ward, Oct 2, 2007
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. codehead
    Replies:
    3
    Views:
    390
    codehead
    Jun 13, 2005
  2. Replies:
    2
    Views:
    428
  3. Thomas McLean

    Python complaining about CherryPY?

    Thomas McLean, Aug 19, 2006, in forum: Python
    Replies:
    0
    Views:
    346
    Thomas McLean
    Aug 19, 2006
  4. Replies:
    6
    Views:
    467
  5. Replies:
    9
    Views:
    292
    Victor Bazarov
    Oct 6, 2005
Loading...

Share This Page