James Hawkins wrote:
Hi,
This patch is based on a patch written by Stefan Huehner in 2005. With the -Wcast-qual warning turned on, these five wine-internal unicode functions produce over 1400 warnings:
strchrW, strrchrW, strpbrkW, memchrW, memrchrW
This patch gets rid of those warnings. Any ideas about this guys?
[...]
I think this sort of double casting is the way to go. I would just mention a couple of possible caveats. When I discussed this with Alexandre, some time back, he expressed a concern that he didn't want to see this kind of thing proliferate throughout the code base, so I would suggest that this type of fix should be confined to a small number of very specific functions (typically string functions that take in a const string and return a non-const version: there are others like this elsewhere) and be applied inline, rather than with a macro, so as not to put temptation in anyone's way. The second point I would make is that - and I haven't tested this on gcc - if, say, ULONG_PTR is bigger than the size of a WCHAR * on any system we support, the compiler might warn of a possible truncation loss when the outer (WCHAR *) cast converts back to a pointer, which would be rather unfortunate. :)
I presume ULONG_PTR is good for both Win32 and Win64.
-- Andy.