Philipp Klaus Krause <
[email protected]> writes:
There are 4 functions (getenv, localeconv, setlocale, strerror) in the standard library that return a pointer and state that the return value
points to something that "shall not be modified by the program". I
suggest to make these functions return pointers-to-const, e.g.
change
char *strerror(int errnum);
to
const char *strerror(int errnum);
A draft proposal is at http://www.colecovision.eu/stuff/proposal-const-shall-not-be-modified-stdlib.html
The formatting of the last paragraph on that web page could be improved.
Do you see any problem with this change?
It would likely break existing code, for the same reason that making
string literals const would break existing code.
Any program that has something like:
char *username = getenv("USER");
would have to be modified. That would include any pre-ANSI code that
calls getenv.
(C++ has made some tweaks to some C standard library functions, and it
*could* have modified getenv in this way, but it hasn't.)
I was wondering if it make sense to also change the char * members of
struct lconf to const char *, but I fear that change might break more stuff.
I think you mean lconv, and that would likely present the same problem.
--
Keith Thompson (The_Other_Keith)
[email protected]
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)