Quoting Andy Ross :

> The confusion seems to be that Microsoft declared strchr() as taking
> and returning a const pointer.  Which is broken, because strchr()
> returns a pointer into the *same* memory it got.  The constness needs
> to be synchronized between the pointers, which is outside the
> capabilities of the C language.  So programmers have to choose between
> a slightly "unsafe" function that drops const and one that requires a
> cast to use with a non-const string.

No, the confusion seems to come from the difference between standard C runtime
and standard C++ runtime. MSVC8 wants to conform to the latter when compiling
C++ code. Look at that page :
http://www.cplusplus.com/reference/clibrary/cstring/strrchr.html

In C++, we now have :
const char *strrchr( const char *, int );
      char *strrchr(       char *, int );
that preserve constness

and in C :
char *strrchr( const char *, int );
that drop constness

a const_cast ( or simply a cast ) wouldn't make the code worse than it is now.

-Fred

-- 
Frédéric Bouvier
http://frfoto.free.fr                      Photo gallery - album photo
http://www.fotolia.fr/p/2278/partner/2278  Other photo gallery
http://fgsd.sourceforge.net/               FlightGear Scenery Designer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to