[fw]error: aggregate value used where an integer was expected
一個自訂struct型態的變數,若想要轉換為unsigned,直接使用cast,gcc(version 4.4.3)編譯會回報錯誤。
例如:
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
解決方法是,改為
printf("var = %x\n", *(unsigned *)&var);