[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check for redundancy
From: |
Yuri Khan |
Subject: |
Re: Check for redundancy |
Date: |
Fri, 3 Jul 2015 17:48:28 +0600 |
On Fri, Jul 3, 2015 at 12:41 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Nowadays (since ≈2002?) the SDK defines a strict mode, where different
>> kinds of handles become pointers to different tag structure types:
>>
>> struct tagWND; // declared but not defined
>> typedef struct tagWND* HWND;
>
> Perhaps in MSVC compiler, not in MinGW. With MinGW, something similar
> happens only if you compile with -DSTRICT (which is rarely, if ever,
> done). And even in MSVC headers I see something significantly
> different from what you show above, and it's also conditioned by
> STRICT being defined.
Yes. -DSTRICT has been the default setting for new projects created in
MSVC++ since version 7 or so. Is there some problem enabling STRICT on
MinGW, or a reason why it is done rarely?
How is it significantly different? Here’s what I see in some ancient copy:
// in winnt.h
#ifdef STRICT
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef
struct name##__ *name
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
// in windef.h
DECLARE_HANDLE (HWND);
DECLARE_HANDLE (HHOOK);
OK, it’s not an undefined struct, it’s a struct with a unique type
name and a single unused int field. This does not affect the type
system, as neither C nor C++ have structural typing. Leaving the
struct undefined would probably be a bit safer.
Re: Check for redundancy, tomas, 2015/07/03
Message not available