__attribute__((aligned(n))):表示指定類型的變量的最小對齊(以字節(jié)為單位)。
十載的漳縣網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整漳縣建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“漳縣網(wǎng)站設(shè)計(jì)”,“漳縣網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。如果結(jié)構(gòu)中有成員的長度大于n,則按照大成員的長度來對齊。
或者以下寫法:
__alignof(16)
__attribute__((packed)):表示取消在編譯過程中的優(yōu)化對齊。
2.程序例子typedef struct {
uint16_t version; // version of the info structure
uint16_t size; // total size of the structure including version and size
uint32_t sample_rate; // sample rate in Hz
audio_channel_mask_t channel_mask; // channel mask
audio_format_t format; // audio format
audio_stream_type_t stream_type; // stream type
uint32_t bit_rate; // bit rate in bits per second
int64_t duration_us; // duration in microseconds, -1 if unknown
bool has_video; // true if stream is tied to a video stream
bool is_streaming; // true if streaming, false if local playback
uint32_t bit_width;
uint32_t offload_buffer_size; // offload fragment size
audio_usage_t usage;
audio_encapsulation_mode_t encapsulation_mode; // version 0.2:
int32_t content_id; // version 0.2: content id from tuner hal (0 if none)
int32_t sync_id; // version 0.2: sync id from tuner hal (0 if none)
} __attribute__((aligned(8))) audio_offload_info_t;
結(jié)構(gòu)體按audio_offload_info_t按最8字節(jié)對齊。
3.調(diào)試#includeint main(){
//1.int
typedef int more_aligned_int __attribute__((aligned(16)));
printf( "aligned: %ld, %ld\n", alignof(int), alignof(more_aligned_int)); // 4, 16
//2.struct
struct S3 {more_aligned_int f;};
struct S4 {int f;};
printf( "S3 size: %ld, S4 size: %ld\n", sizeof(struct S3), sizeof(struct S4)); // 16, 4
//3.array
int arr[2] __attribute__((aligned(16))) = {1, 2};
printf( "arr size: %ld, arr aligned: %ld\n", sizeof(arr), alignof(arr)); // 8, 16
//4.packed
struct S6 {more_aligned_int f;} __attribute__((packed));
printf( "S6 size: %ld\n", sizeof(struct S6)); // 4
//5.double
struct S7 {double f;} __attribute__((aligned(4)));
printf( "S7 size: %ld, algined: %ld\n", sizeof(struct S7), alignof(struct S7)); // 8, 8
struct S8 {double f;} __attribute__((__aligned__(32)));
printf( "S8 size: %ld, algined: %ld\n", sizeof(struct S8), alignof(struct S8)); // 32, 32
return 0;
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧