Wide-string Functions: Double Casting

Eric Pouech eric.pouech at wanadoo.fr
Sat Aug 12 01:35:51 CDT 2006


David Laight wrote:

>On Tue, Aug 08, 2006 at 09:27:23PM +0200, Eric Pouech wrote:
>  
>
>>what I don't like is that in order to plug a hole (casting from const 
>>foo* to foo*), we create a bigger hole by allowing to cast from const 
>>foo* to bar* (and the compiler will not give any warning)
>>if we want to go into this, then I'd rather have _deconst explicitly use 
>>the type:
>>#define __deconst(v,X)    ({const X _v = (v); ((X)(int)_v);})
>>and in the previous example use __deconst(str, char*);
>>    
>>
>
>That isn't valid C, you could do:
>	((const X)(v) - (v), (X)(int)(v))
>but that is likely to give a 'computed value not used' warning instead.
>
>What you really don't want to do is allow casts from 'int' to 'foo *'.
>After all casting from 'foo *' to 'bar *' is easy.
>
>	David
>
>  
>
this is supported by gcc...
of course we'd need to define differently the macro for gcc and other 
compilers
but casting from foo* to bar* is (in most of the cases) a sign of bad design
A+



More information about the wine-devel mailing list