Wide-string Functions: Double Casting
Andrew Talbot
Andrew.Talbot at talbotville.com
Mon Aug 7 17:42:23 CDT 2006
David Laight wrote:
> On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote:
>> would like to submit a patch that, for example, changes strchrW() to:
>>
>> extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
>> {
>> WCHAR *ret = NULL;
>> do { if (*str == ch) ret = (WCHAR *)(size_t)str; } while (*str++);
>> return ret;
>> }
>
> why not just have:
>
> extern inline void *__deconst(const void *v)
> {
> return (char *)0 + ((const char *)v - (const char *)0));
> }
>
> Then the code above could be:
> extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
> {
> do { if (*str == ch) return __deconst(str); } while (*str++);
> return 0;
> }
>
> David
>
That's interesting. IMHO, it's a bit more complex and obscure, but seems to
ensure portability. I shall be interested to know what others think.
Thanks,
-- Andy.
More information about the wine-devel
mailing list