![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Ok, why would you do this?
Thanks,
Elizabeth (another C illiterate)
At 06:53 PM 10/30/2000 -0500, you wrote:
>Hi Mike:
>
>You wrote:
> >
> > Could anyone explain to a C illiterate how to interpret a C class union?
> >
>
>A union in C gives the bytes in question "multiple personalities". As
>far as the compiler is concerned the names refer to the same bytes. if
>you call
>
> > For example:
> >
> > -------------------------------------------------
> > typedef struct _PROPSHEETPAGE {
> > DWORD dwSize;
> > DWORD dwFlags;
> > HINSTANCE hInstance;
> > union {
> > LPCSTR pszTemplate;
> > LPCDLGTEMPLATE pResource;
> > };
>
> Here you can refer to _PROPSHEETPAGE.pszTemplate or
>_PROPSHEETPAGE.pResource and you will get the data at the same
>address. If one of the types is larger than the other the larger
>number of bytes would be allocated and of course the extra bytes would
>be unused when storing a smaller type. But
> >
> > -------------------------------------------------
> > CLASS PROPSHEETPAGE
> > VARIABLE dwSize
> > VARIABLE dwFlags
> > VARIABLE hInstance
> > \ union
> > VARIABLE pszTemplate
> > VARIABLE pResource
>
>this will not work correctly. You need only one variable for each of
>the unions (provided the type is covered by four bytes.
>
>And noe the ubiquitous HTH :)
>
>--
>John McKeon
>jmck_at_customsightsound.com
>
>_______________________________________________
>Sftalk mailing list Sftalk_at_forth.com
>Visit Sftalk on the web at http://www.forthinc.com/mailman/listinfo/sftalk
================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-372-8493
111 N. Sepulveda Blvd. #300 Fax: +1 310-318-7130
Manhattan Beach, CA 90266
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
================================================
Received on Mon Oct 30 2000 - 16:18:12 PST
This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:29 PST