2016-04-27 84 views
0

這是什麼代碼行平均的:C和C++奇數語法「unsigned int:32;」

unsigned int     :32  ; 

它來源於:

 typedef struct avr32_pwm_channel_t { 
     union { 
       unsigned long     cmr  ;//0x0000 
       avr32_pwm_cmr_t    CMR  ; 
     }; 
       unsigned long     cdty  ;//0x0004 
       unsigned long     cprd  ;//0x0008 
     const unsigned long     ccnt  ;//0x000c 
       unsigned long     cupd  ;//0x0010 
       unsigned int     :32  ;//0x0014 
       unsigned int     :32  ;//0x0018 
       unsigned int     :32  ;//0x001c 
    } avr32_pwm_channel_t; 

我嘗試使用Google,但沒有發現任何

+0

查找位字段。 – DeiDei

+0

謝謝我現在在讀它 –

回答

1

這就是所謂的位字段。它決定了每個結構體的寬度。

請參閱https://en.wikipedia.org/wiki/Bit_field

+0

我們如何區分這3個結構體的成員?無符號整數:32; // 0x0014 unsigned int:32; // 0x0018 unsigned int:32; // 0x001c' 因爲它們沒有名字,請您詳細解釋一下。 –

+0

那些是一些填充位。 – Ouss4

+0

aha ...謝謝 也這個鏈接解釋它比wiki更好 http://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html –