Cast-qual warning fix

Andrew Talbot Andrew.Talbot at talbotville.com
Sun Nov 5 11:24:10 CST 2006


Dmitry Timoshkov wrote:

> "Andrew Talbot" <Andrew.Talbot at talbotville.com> wrote:
> 
>> -typedef void *MSIITERHANDLE;
>> +typedef void        *MSIITERHANDLE;
>> +typedef const void  *MSICITERHANDLE;
> 
> Personally I don't like MSICITERHANDLE typedef at all. It' not obvious
> that 'C' in the name marks constness of the object. Using 'const'
> explicitly such as 'const MSIITERHANDLE *handle' is much more clear and
> readable IMO.
> 

I share your lack of affection for the name, but there is a subtle point
here that is not universally known.

Consider the following declaration.

    typedef char *PCHAR;

PCHAR is a pointer, so

    const PCHAR p;

declares a constant pointer, not a pointer to constant. In other words it is
equivalent to

    char *const p;

not
    const char *p;

In our case, MSIITERHANDLE is declared as a pointer to void, so

    const MSIITERHANDLE *handle;

is equivalent to

    void *const *handle;

whereas

   MSICITERHANDLE *handle;

is equivalent to

   const void **handle;

which, I believe, is what is required. Hence, my new type definition.

If the type had a name like LPSTR, I would call my const-qualified version
LPCSTR. Hence why I put the "C" in that awkward position.

-- Andy.





More information about the wine-devel mailing list