Windows is, of course, very particular about the structures passed to it in API
calls. To summarize my new understanding of C unions:
Apparently, C unions were devised to make "double duty" of existing structures
by renaming and retyping (very important for C) certain members. In the
Property Sheet example below, additional functionality was added simply by
defining new values for the dwFlags member. So with one dwFlags value, the data
type LPCSTR would be expected (demanded) by the C compiler, while a different
dwFlags value would expect the data type LPCDLGTEMPLATE.
typedef struct _PROPSHEETPAGE {
DWORD dwSize;
DWORD dwFlags;
HINSTANCE hInstance;
union {
LPCSTR pszTemplate;
LPCDLGTEMPLATE pResource;
};
...
Many thanks to all who responded,
Mike
----- Original Message -----
From: "Elizabeth D Rather" <erather_at_forth.com>
To: <sftalk_at_forth.com>
Sent: Monday, October 30, 2000 4:05 PM
Subject: Re: [sftalk] C Unions
> Ok, why would you do this?
>
> Thanks,
> Elizabeth (another C illiterate)
>
Received on Mon Oct 30 2000 - 16:47:23 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.