相关疑难解决方法(0)

除int之外的其他类型的位域?

我有一个代码,它使用如下声明的位字段

typedef struct my{
    const char *name;
    uint8_t is_alpha : 1;   
    uint8_t is_hwaccel : 1; 
    uint8_t x_chroma_shift; 
    uint8_t y_chroma_shift; 

} mystr; 
Run Code Online (Sandbox Code Playgroud)

uint8_t是typedef'ed unsigned char.

使用此位字段在MS-VS 2008中构建代码会发出如下警告:

imgconvert.c(60) : warning C4214: nonstandard extension used : bit-field types other than int.
  1. 使用除int之外的其他类型的位字段是否存在任何问题/潜在问题?为什么警告?
  2. C99 C语言规范是否允许使用int类型的bit-fileds以外的其他文件?

c visual-c++ bit-fields

10
推荐指数
1
解决办法
8132
查看次数

标签 统计

bit-fields ×1

c ×1

visual-c++ ×1