首页 > 题库 > 职业考证 > 软考 > 嵌入式系统设计师 > 单选题

假设以下代码运行环境为32位系统,其中,attribute((packed))的作用是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐。
代码段1:
 struct student1 {
    char name [10];
    long sno;
    char sex;
    float score[4] ;
}_attribute__( (packed)) *p1, a1, b1;


代码段2:
 union student2 {
    char name [10] ;
    long sno;
    char sex;
    float score[4];
} *p2, a2, b2;


sizeof(struct student1)、sizeof(union student2)的结果分别是(  )。

问题1选项
A.248和128
B.31和31
C.31和16
D.16和16
参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷