Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Philipp Klaus Krause <pkk@spth.de> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Return pointers-to-const where data shall not be modified |
| Date | 2020-05-06 19:25 +0200 |
| Organization | solani.org |
| Message-ID | <r8urv8$82c$1@solani.org> (permalink) |
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 Do you see any problem with this change? 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. Philipp
Back to comp.std.c | Previous | Next — Next in thread | Find similar | Unroll thread
Return pointers-to-const where data shall not be modified Philipp Klaus Krause <pkk@spth.de> - 2020-05-06 19:25 +0200
Re: Return pointers-to-const where data shall not be modified Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-06 13:18 -0700
Re: Return pointers-to-const where data shall not be modified Chris Peterson <cpeterson@mozilla.com> - 2020-08-19 10:44 -0700
Re: Return pointers-to-const where data shall not be modified Philipp Klaus Krause <pkk@spth.de> - 2020-08-28 11:40 +0200
Re: Return pointers-to-const where data shall not be modified James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-28 08:42 -0400
csiph-web