"Andrew Talbot" Andrew.Talbot@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.
Dmitry Timoshkov wrote:
"Andrew Talbot" Andrew.Talbot@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.
Andrew Talbot Andrew.Talbot@talbotville.com writes:
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.
Actually from reading the code there doesn't seem to be a reason for having the non-const variant, and also no reason to use a void* instead of a proper type. The definition should probably be something like "typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE".