On Saturday 07 October 2006 12:03, Andrew Talbot wrote:
The problem with that is that sometimes these functions are called with writeable strings, and the return value is used to modify the original
Yes, that's why I suggested making a copy or writing a local wrapper that removes the constness.
Another solution might be, where appropriate - such as in strchrW() - to replace certain functions with versions that, instead of returning a pointer, returns an offset from the start of the string using a signed integer type, i.e., in this case, declared as something like:
Rewriting the code to avoid the problematic functions is a third option. I find the approach that solves the constness issues locally better than the one that casts the constness away in the global functions. The reason is that there may be better options available locally than to simply cast the constness away.
-Hans