why do string functions use char not const?

2011-04-04
2013-03-12
  • Mark Richardson

    Mark Richardson - 2011-04-04

    I was porting some code and came across the error
    file1.c:100: warning 196: pointer target lost const qualifier

    Looking into this, all the prototypes in string.h use (char*) not (const char*).  My functions all take (const char*) arguments, so when I pass them onto strlen() I get the warning - yeah, I can turn off the warning or typecast, but I'm a little worried that the strlen() function could change my strings.

    Anyone know for sure if strlen() affects the passed pointer? If not, then anyone know why the "const" qualifier wasn't used?

     
  • Maarten Brock

    Maarten Brock - 2011-04-04

    What version of SDCC are you using and for which target are you compiling?

     
  • Mark Richardson

    Mark Richardson - 2011-04-04

    I'm compiling for pic18f4455 and I'm using the pre-built  SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.0 #6037 (Oct 31 2010) (MINGW32)

    Don't give me too much trouble (some is ok) for using windoze, I'm rebuilding my linux box so I have to make do for now!

    The prototypes in SDCC/include/pic16/string.h all use char, not const char.

     
  • Maarten Brock

    Maarten Brock - 2011-04-06

    For the pic16 SDCC is still in beta stage.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks