Re:Deciding to rewrite getaddrinfo in rust
by lmb on Tuesday February 23, 2016 @10:51AM
(#11159683)
The comment about changing the const pointers is subtly wrong. There are pointers to const memory and there are const pointers to memory. My favourite little known C fact. See also http://stackoverflow.com/questions/1143262/
[ Parent
| on HN ]
Re:Deciding to rewrite getaddrinfo in rust
by delroth on Tuesday February 23, 2016 @10:57AM
(#11159731)
That's not really "little known". Almost every single piece of code that does string manipulation in C uses that fact:
const char* s = ...;
while (*s++) { ... }I think you have proven my point. I'm talking about this:
void something(const char* const s);
Maybe I'm extrapolating here, but it surprised me.
Re:Deciding to rewrite getaddrinfo in rust
by dcohenp on Tuesday February 23, 2016 @04:39PM
(#11162566)
That is indeed what the post you're replying to meant. Note that the pointed-to value is a constant string, yet the pointer itself is being modified. That's a fairly common idiom in C string-handling code, only possible because it's a const char , not a const char const.
Re:Deciding to rewrite getaddrinfo in rust
by aidenn0 on Tuesday February 23, 2016 @12:18PM
(#11160458)
constant pointers are arguably little-known, though pointers to constants are well known.
Re:Deciding to rewrite getaddrinfo in rust
by asveikau on Tuesday February 23, 2016 @12:26PM
(#11160529)
Agree with the other comments that this is most decidedly not "little known". The author loses all credibility in all C topics for saying this is poor form.
Not sure who your issue is with, me or the author of the article?