FROM : Steven Noyes
DATE : Wed Apr 04 17:58:36 2007
One thing to watch out for (and you may have it covered) is the crc
[2]. With both PPC and Intel that you have to worry about, make sure
you keep you Endian Orders right.
Steven
On Apr 3, 2007, at 8:44 PM, Mike wrote:
> Are unions supported in Obj-C? If so is there anything special I
> have to do to use them?
>
> In my .h file I define a union like this:
>
> typedef struct
> {
> char type;
> char version;
> char oem[ SER_OEM_SIZE ];
> char alpha_chk[ 2 ];
> char number[ SER_NUM_SIZE ];
> char crc[ 2 ];
> } serial_rec;
>
> union serial_buff
> {
> serial_rec s;
> char c[ sizeof( serial_rec ) ];
> };
>
> I then import that.h file into my .m file but any time I try to use
> the union I get an error on the declaration of my union serial_buff s:
>
> - (BOOL)_validateSerialNumberAlpha:(char*)pserial_number
> {
> BOOL result = NO;
> serial_buff s;
>
> memset( &s, 0, sizeof( s ) );
> memmove( s.c, pserial_number, ( strlen( pserial_number ) >
> sizeof( s.c )) ? sizeof( s.c ) : strlen( pserial_number ) );
> .
> .
> .
>
> Thanks,
>
> Mike
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Wed Apr 04 17:58:36 2007
One thing to watch out for (and you may have it covered) is the crc
[2]. With both PPC and Intel that you have to worry about, make sure
you keep you Endian Orders right.
Steven
On Apr 3, 2007, at 8:44 PM, Mike wrote:
> Are unions supported in Obj-C? If so is there anything special I
> have to do to use them?
>
> In my .h file I define a union like this:
>
> typedef struct
> {
> char type;
> char version;
> char oem[ SER_OEM_SIZE ];
> char alpha_chk[ 2 ];
> char number[ SER_NUM_SIZE ];
> char crc[ 2 ];
> } serial_rec;
>
> union serial_buff
> {
> serial_rec s;
> char c[ sizeof( serial_rec ) ];
> };
>
> I then import that.h file into my .m file but any time I try to use
> the union I get an error on the declaration of my union serial_buff s:
>
> - (BOOL)_validateSerialNumberAlpha:(char*)pserial_number
> {
> BOOL result = NO;
> serial_buff s;
>
> memset( &s, 0, sizeof( s ) );
> memmove( s.c, pserial_number, ( strlen( pserial_number ) >
> sizeof( s.c )) ? sizeof( s.c ) : strlen( pserial_number ) );
> .
> .
> .
>
> Thanks,
>
> Mike
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Mike | Apr 4, 05:44 | |
| Spencer Salazar | Apr 4, 06:21 | |
| Shawn Erickson | Apr 4, 06:25 | |
| Brian Bergstrand | Apr 4, 06:29 | |
| Mike | Apr 4, 08:12 | |
| Steven Noyes | Apr 4, 17:58 |






Cocoa mail archive

