我工作的一個網絡項目,我碰到這個結構的骨架代碼來到我工作的結構體遇到問題:理解用C
struct sr_icmp_hdr {
uint8_t icmp_type;
uint8_t icmp_code;
uint16_t icmp_sum;
} __attribute__ ((packed)) ;
typedef struct sr_icmp_hdr sr_icmp_hdr_t;
有人能解釋代碼的結構如下是什麼?什麼是__attribute__
或typedef
?
我已經習慣了在C++中看到的是:
struct hi{
int thisIsAnInt;
double thisIsADouble;
}
,並宣佈這樣的結構:
hi hello;
cout << hello.thisIsAnInt;
在C有何不同?
我不會調用屬性「noise」;這是一個gcc特定的擴展(儘管在這種情況下它可能沒有效果)。 –
我正在編輯屬性評論,因爲你評論。我認爲這是噪音,但我已經給出了它更完整的特徵,以及爲什麼我認爲它是噪音。 –