小编glo*_*fer的帖子

切换错误::不能出现在常量表达式中

这是一个奇怪的...

我正在玩一些减压算法.char buffer[]buffer[i]找到停止位之前,我没有经过和循环 ,而是尝试使用一些位掩码技术但是使用字符.

我有以下示例:

// In a *.h file  
const char ch = '\x81';  
// To avoid Endianess  
union CharUInt  
{  
    char sz[4];  
    unsigned int u;  
};  
// Legal because char[] is declared before uint32 in the union  
const CharUInt Mask1 = {'\x81', '\x0', '\x0', '\x81'};  
const CharUInt Mask2 = {'\x0', '\x81', '\x81', '\x0'};  
// Proxy / Auxillary uint32 as usimg Mask2.u in the switch blocked produced the same errors  
const unsigned int uMask1 = …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors switch-statement

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

compiler-errors ×1

switch-statement ×1