Marcus Meissner wrote:
I asked our gcc gurus.
- If you want to cast, do not use size_t but uintptr_t.
Or:
Do not inline the function, and compile its file without -Wcast-qual.
Fix the prototype to read "extern inline const WCHAR *strrchrW( const
WCHAR *str, WCHAR ch )"
Ciao, Marcus
intptr_t and uintptr_t were, of course, introduced in C99 specifically to be integer types to which any valid pointer to an object may be converted. This is the ultimate way to go, I believe, but I would need help or advice to patch the appropriate make file to cater for users with non-C99 systems.
Incidentally, regarding the other suggested solutions: IMHO, I don't think it a good idea to remove the inlining, thus adding the overhead of a function call to these functions. And if one constifies the return value, then it becomes no longer possible to write code like:
WCHAR arrW[] = {'b','i','t',0}, *pwc;
if ((pwc = strrchrW(arrW, 'i')) != NULL) *pwc = 'a';
Thanks,
-- Andy.