Tag Archives: [fw]error: aggregate value used where an integer was expected

[Solved] error: aggregate value used where an integer was expected

If you want to convert a variable of custom struct type to unsigned, you can directly use cast. GCC (version 4.4.3) compilation will report an error

for example:

struct _test {
 unsigned hour : 5;
 unsigned minute : 6;
};

struct _test var = {5, 6}
printf("var = %x\n", (unsigned)var);

error: aggregate value used where an integer was expected

Solution:

printf("var = %x\n", *(unsigned *)&var);