Hi Gustavo,
Just tried it in your code, and It's still aligning on a 4 byte boundary.
As you can see bellow I added a unsigned char variable in order to make struct out of alignment,
I used the attribute you talked about and still got 3 bytes padding added to the structure, which means that regardless of the attribute declaration it is still aligning to a 4 byte boundary.
typedef struct __attribute__ ((packed,aligned(2)))
{
unsigned long ChunkID;//4 bytes = "RIFF" 0x52494646 big-endian form
unsigned long ChunkSize;//4 bytes
unsigned long Format; //4 bytes = "WAVE" 0x57415645 big-endian form
unsigned long Subchunk1ID; //4 bytes = "fmt" 0x666d7420 big-endian form
unsigned long Subchunk1Size; //4 bytes
unsigned short AudioFormat;//2 bytes: 0 =???; 1 = Linear quantization; Others = compression
unsigned short NumChannels;//2 bytes: Mono = 1; Stereo = 2; etc.
unsigned long SampleRate;//4 bytes: 8000, 44100, etc.
unsigned long ByteRate;//4 bytes: SampleRate * NumChannels * BitsPerSample/8
unsigned short BlockAlign;//2 bytes: NumChannels * BitsPerSample/8
unsigned short BitsPerSamples;//2 bytes: 8 = 8 bits; 16 = 16 bits; etc.
unsigned long Subchunk2ID;//4 bytes = "data" 0x64617461 big-endian form
unsigned long Subchunk2Size;//4 bytes: NumSamples * NumChannels * BitsPerSample/8
unsigned char x;
// unsigned long Data;//(ChunkSize) bytes
} WAVE_FILE;
If the compiler were aligning the data to a 2 byte boundary, you should only get one padding byte.
Stil, thanks for all the time you're wasting on my problem!!
Best Regards,