Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 铿锵的c++;11缩小_C++_Clang - Fatal编程技术网

C++ 铿锵的c++;11缩小

C++ 铿锵的c++;11缩小,c++,clang,C++,Clang,如果我根据clang编译gcc代码,我会得到一个错误: non-constant-expression cannot be narrowed from type 'int' to 'BYTE' (aka 'unsigned char') in initializer list [-Wc++11-narrowing] 本在线: const BYTE pattern[4] = {0x00, 0x00, m_outTrackFormat == BS_RTF_MODE2_FORM1 ? 0x80 :

如果我根据clang编译gcc代码,我会得到一个错误:

non-constant-expression cannot be narrowed from type 'int' to 'BYTE' (aka 'unsigned char') in initializer list [-Wc++11-narrowing]
本在线:

const BYTE pattern[4] = {0x00, 0x00, m_outTrackFormat == BS_RTF_MODE2_FORM1 ? 0x80 : 0x00, 0x00};
这里发生了什么变化

缩小转换定义如下:

列表初始化通过以下方式限制允许的隐式转换 禁止下列行为:

从整数或非范围转换 枚举类型转换为整数类型,不能表示 原始的,,除非源是一个值为 可以准确地存储在目标类型中

,C++中没有8位。因此,与其他参数不同,由于三元运算符使用非常量变量,因此有一个非常量

int
参数,需要将其转换为
BYTE
,从而导致编译错误


顺便说一句,我可以在clang和gcc中复制它。

我不知道在代码的和平中哪里有int。只有一个全局定义,这是编译的int吗?顺便说一句,gcc可以很好地编译代码,只是clangnags.0x80和0x00的类型为int,因为这是整数文本的最小类型