Hi,
After spending a day trying to debug a problem I narrowed it down to a 7-byte packed structure that the IDE is compiling as 8 bytes.
Here is a simplified sketch to reproduce the problem:-
void setup() {
// put your setup code here, to run once:
typedef struct quest_st
{
uint32_t kern;
uint8_t chCount;
union
{
uint8_t asAmpli;
struct
{
uint8_t dir : 4;
uint8_t curve : 4;
};
} uAmpli;
union
{
uint8_t asForce;
struct
{
uint8_t amount : 5;
uint8_t axis : 3;
};
} uForce;
} QUEST __attribute__((packed));
int ss;
QUEST myQuest;
char buf[ 80];
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Program start.");
delay(200);
if( &ss != NULL)
ss = sizeof( QUEST);
sprintf( &buf[0], "\n sizeof( QUEST) = %ld sizeof(myQuest) = %ld"
" sizeof( struct quest_st) = %ld", ss, sizeof( myQuest), sizeof( struct quest_st));
Serial.println( &buf[0]);
}
void loop() {
// put your main code here, to run repeatedly:
}
The IDE installed tree has not been changed in any way ...I am using the same version of the compiler that came with it originally in 1.5.2 release.
There is no warning of ignored attribute command (which I get in gcc on Fedora).
Is there a way to make that sizeof() operator behave correctly? May be with some compiler flags?
Thanks.