gpt4 book ai didi

C 错误 : braced-group within expression allowed only inside a function

转载 作者:太空宇宙 更新时间:2023-11-04 00:05:40 27 4
gpt4 key购买 nike

在 C 中,我有这样的语句:

unsigned char const Alpha[6][2] = (unsigned char)({
{ 0x90f }, { 0x92c, 0x940 }, { 0x938, 0x940 },
{ 0x921, 0x940 }, { 0x908 }, { 0x90f, 0x92b }
});

但它会产生错误,因为 braced-group within expression allowed only inside a function

任何人都可以提出补救措施。

注意:Alpha 是一个全局常量,因此它在任何函数之外。

最佳答案

您不需要复合字面量并且您的值对于 unsigned char 来说太大了,更改为:

unsigned short int const Alpha[][2] = {
{ 0x90f }, { 0x92c, 0x940 }, { 0x938, 0x940 },
{ 0x921, 0x940 }, { 0x908 }, { 0x90f, 0x92b }
};

关于C 错误 : braced-group within expression allowed only inside a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25380352/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com