gpt4 book ai didi

c++ - 用于函数时结构上的二进制 "["错误

转载 作者:行者123 更新时间:2023-11-28 00:55:28 25 4
gpt4 key购买 nike

我正在尝试制作一个 Q3BSP map 信息调试器。

我卡在了纹理调试部分,这是那部分使用的代码:

for( i = 0; i < nTextures; i++ ) {
printf( "Texture id %d\n", i );
printf( "\tTexture name %s\n", Texture[i].name );
printf( "\tTexture flags %d\n", Texture[i].flags );
printf( "\tTexture contents %d\n", Texture[i].contents );
}

但是这种错误似乎出现了:

error C2676: binary '[' : 'Q3BSPTexture' does not define this operator or a conversion to a type acceptable to the predefined operator

这是 Q3BSPTexture 结构:

typedef struct {
char name[64]; // Texture name.
int flags; // Surface flags.
int contents; // Surface contents
} Q3BSPTexture;

我怀疑结构没有像 char [32]

那样设置限制

但我喜欢听专业人士的解决方案!

最佳答案

您还没有向我们展示 Texture 的定义。

您将 Texture 视为 Q2BSPTezture 的数组。显然它是一个单独的 Q2BSPTezture 对象,因此对其进行索引没有意义。您可能只需要将其声明为数组,或者声明为指向您需要分配的数组第一个元素的指针。

此外,错误消息暗示您正在编译 C++,而不是 C(在 C 中,类型不可能定义任何运算符)。

关于c++ - 用于函数时结构上的二进制 "["错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11655704/

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