我有一個嵌套的結構定義如下:嵌套結構說:「警告:指針和整數之間的比較」
/* Buffering incoming CAN messages */
union CANDATA // Unionize for easier cooperation amongst types
{
unsigned long long ull;
signed long long sll;
u32 ui[2];
u16 us[4];
u8 uc[8];
u8 u8[8];
s32 si[2];
s16 ss[4];
s8 sc[8];
};
struct CANRCVBUF // Combine CAN msg ID and data fields
{ // offset name: verbose desciption
u32 id; // 0x00 CAN_TIxR: mailbox receive register ID p 662
u32 dlc; // 0x04 CAN_TDTxR: time & length p 660
union CANDATA cd; // 0x08,0x0C CAN_TDLxR,CAN_TDLxR: Data payload (low, high)
};
struct CANRCVTIMBUF // CAN data plus timer ticks
{
union LL_L_S U; // Linux time, offset, in 1/64th ticks
struct CANRCVBUF R; // CAN data
};
我的變量的聲明如下:
static struct CANRCVTIMBUF* pfifo1; // Pointer to CAN driver buffer for incoming CAN msgs, high priority
我想我正在圍繞着這裏指針發生的事情,但我正在嘗試訪問pfifo1的id值:
if(&pfifo1->R.id == 0x44200000) { // Message to toggle blue led
toggle_led(15);
}
這給了我該行的警告warning: comparison between pointer and integer
。我的想法是,&pfifo1->R
會讓我CANRCVBUF
結構,從中我可以使用.
訪問ID ...不幸的是,似乎並非如此