三维数组初始化

发布于 2024-10-05 16:19:30 字数 265 浏览 0 评论 0原文

在我正在查看的一些代码中,一个 3D 数组已像这样初始化:(

static const char codeset[6][256][10] = {
    [0] = { [0x20] = " ",
    [0x21] = "!",
    [0x22] = """,
    [0x23] = "#",
}};

它确实继续初始化其余单元格,我已将其剪短以显示可读的内容。)

这不会编译。是应该的吗?这是怎么回事?

In a bit of code I'm looking at, a 3D array has been initialized like so:

static const char codeset[6][256][10] = {
    [0] = { [0x20] = " ",
    [0x21] = "!",
    [0x22] = """,
    [0x23] = "#",
}};

(It does go on to initialize the rest of the cells, I've cut it short to show something readable.)

This does not compile. Is it supposed to? What's going on here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

無心 2024-10-12 16:19:31

作为猜测,它试图为 xml 字符串 ASCII 数据创建“字母表”。 xml 中的 "(双引号)字符表示为 "。因此 [0][0 - 255] 组是 xml。

它看起来像一个等价表。它从 xml 转换为 ASCII 或其他形式。

As a guess, it trying to create the "alphabet" for xml string ASCII data. The " (double quote) character in xml is represented as ". So the [0][0 - 255] group is xml.

It looks like an equivalence table. It translates from xml to ASCII or whatever.

我是男神闪亮亮 2024-10-12 16:19:30

您正在使用 C99 初始值设定项,但您的编译器不支持 C99 或未启用 C99。

You are using C99 initializers, but your compiler does not support C99 or C99 is not enabled.

可可 2024-10-12 16:19:30

您正在尝试使用 C99 初始化程序,但很可能您的编译器不是' t C99 兼容,否则它可以工作。

You are trying to use C99 initializers, but most likely your compiler isn't C99-compliant, otherwise it would work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文