• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MFC Porting Issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MFC Porting Issues


  • Subject: Re: MFC Porting Issues
  • From: John Stiles <email@hidden>
  • Date: Sat, 21 Jan 2006 10:23:26 -0800

Ricky Sharp wrote:
typedef struct
{
        BYTE b1[8];
        DWORD height;
        DWORD width;
        WORD w1;
        WORD bitDepth;
        DWORD d2;
        DWORD blockLen;
} IPOD_PICTURE_HEADER;


BYTE = unsigned char DWORD = unsigned long WORD = unsigned char

Along with ensuring proper alignment and byte-swapping of the fields, I strongly suggest the usage of "sized" types that guarantee size (e.g. UInt16, UInt32, Bool8, etc.) You typically define these types in some include/import file where they'd be mapped to the appropriate type that each platform defines.
stdint.h is the standards-compliant way to do this without needing to make your own header for each platform you build on. (uint32_t and friends.)

This is always necessary for structures that will be populated with data from some persistent store.
In all fairness, the size of the Windows types is basically carved in stone. Just about every Win32 app would break horribly if DWORD or WORD changed size. :)
I agree with your principles, but if we're dealing with a Windows-centric codebase, it's probably OK as-is.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >MFC Porting Issues (From: Kevin Wojniak <email@hidden>)
 >Re: MFC Porting Issues (From: Shawn Erickson <email@hidden>)
 >Re: MFC Porting Issues (From: Kevin Wojniak <email@hidden>)
 >Re: MFC Porting Issues (From: Dave Camp <email@hidden>)
 >Re: MFC Porting Issues (From: Kevin Wojniak <email@hidden>)
 >Re: MFC Porting Issues (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Document Packages Examples...
  • Next by Date: Re: Document Packages Examples...
  • Previous by thread: Re: MFC Porting Issues
  • Next by thread: UI for nonuniform Core Data object hierarchy
  • Index(es):
    • Date
    • Thread