对我放轻松,我仍然是 C/C++ 的新手。我知道这已经被问过几次了,我已经尝试按照给出的解决方案无济于事。此代码用于 NetBurner 处理器,DWORD 是 32 位无符号,WORD 是 16 位无符号。
标头 func.h:
class funcs
{
// ...
private:
void myfunc();
WORD data001;
DWORD data002[100];
DWORD data003[100];
// ...
}
我有这个函数调用我的类中的数据,funcs.cpp。假设所有变量都已初始化:
void funcs::myfunc()
{
data001++;
data002[data001] = x; // random x for this example
data003[data001] = y;
}
我的编译器抱怨:“错误:数组下标的无效类型'DWORD [WORD]”。我已将数组下标类型更改为“int”、“unsigned int”和我能想到的所有其他类型,但仍然出现错误。我尝试了之前帖子中给出的解决方案:
void funcs::myfunc()
{
data001++;
this->data002[data001] = x; // random x for this example
this->data003[data001] = y;
}
但这无济于事。我也尝试在类中包含 myfunc 定义,同样的错误。有什么想法/解决方案吗?我难住了。多谢你们!!
编辑:头文件中提供的数据类型:
typedef unsigned char BOOL;
typedef unsigned char BOOLEAN;
typedef unsigned char BYTE; /* Unsigned 8 bit quantity */
typedef signed short SHORT;/* Signed 16 bit quantity */
typedef unsigned short WORD; /* Unsigned 16 bit quantity */
typedef unsigned long DWORD;/* Unsigned 32 bit quantity */
typedef signed long LONG; /* Signed 32 bit quantity */
typedef volatile unsigned char VBOOLEAN;
typedef volatile unsigned char VBYTE; /* Unsigned 8 bit quantity */
typedef volatile short VSHORT; /* Signed 16 bit quantity */
typedef volatile unsigned short VWORD; /* Unsigned 16 bit quantity */
typedef volatile unsigned long VDWORD; /* Unsigned 32 bit quantity */
typedef volatile signed long VLONG; /* Signed 32 bit quantity */
截屏: