网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

C语言之-创新互联

1.aligned定义

__attribute__((aligned(n))):表示指定类型的变量的最小对齐(以字节为单位)。

十载的漳县网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整漳县建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“漳县网站设计”,“漳县网站推广”以来,每个客户项目都认真落实执行。

如果结构中有成员的长度大于n,则按照大成员的长度来对齐。

或者以下写法:

__alignof(16)

__attribute__((packed)):表示取消在编译过程中的优化对齐。

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;

结构体按audio_offload_info_t按最8字节对齐。

3.调试
#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;
}

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


本文题目:C语言之-创新互联
网页地址:http://bjjierui.cn/article/dsipep.html

其他资讯