[Flac-dev] 64-bit FLAC structure sizes and padding

Jerker Bäck jerker.back at gmail.com
Sun May 29 23:43:44 PDT 2011

Erik, thanks for the swift answer. Your right, I haven't seen any issues
yet. But it a thought stroke me when implementing edit capabilities of FLAC
vorbis comments. I've already implemented reading vorbis comments from FLAC
files in 64-bit and it works without any issues. This now leave me a bit
confused, since it should have issues(!).
Using the MS 64-bit compiler on Windows 7/2008R2 64-bit. Static libFLAC
compiled with compiler default 8 byte boundary alignment.

Now consider this:

typedef struct {
    FLAC__uint32 length;
    FLAC__byte *entry;
} FLAC__StreamMetadata_VorbisComment_Entry;

The compiler (with default settings) should interpret this as 

typedef struct {
    FLAC__uint32 length;
    uint32_t __padding;
    FLAC__byte *entry;
} FLAC__StreamMetadata_VorbisComment_Entry;

Sizeof structure: 32-bit - 8 bytes, 64-bit - 16 bytes

How on earth does the compiler find entry correctly when reading (it does,
but how)?
What happens if I edit a vorbis comment/insert a new one when structure size
is doubled?

Am I missing something?

More information about the Flac-dev mailing list