读书人

#039;WORD32#039; : illegal use of this type

发布时间: 2012-02-08 19:52:21 作者: rapoo

'WORD32' : illegal use of this type as an expression
问题是这样出现的:
我把一些C代码移植到C++里面,由于不同的代码,自定义数据类型有些不一样,如C中用word32,而部分C++却用了dword;
我把这些定义放在了一个头文件中;代码如下:
CommonDefs.h

#ifndef _COMMONDEFS_
#define _COMMONDEFS_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif

typedef unsigned char U8;
typedef unsigned short U16;
typedefunsigned long U32;

typedef U8 BYTE;
typedef U16 WORD16;
typedef U32 WORD32;

typedef signed short SWORD16;
typedef signed long SWORD32;

typedef BYTE BOOLEAN;
typedef WORD16 WORD;
typedef WORD32 DWORD;
typedef char CHAR;
typedef void VOID;

#define TRUE 1

#define _BIG_ENDIAN 1

#define BIT2BYTE(bitlen) \
(((bitlen)>>3) + (0 == ((bitlen)&0x7)))


U32 ExtractBitField(U8*,U32 start,U32 len);

U32 U8toU32(const U8 u8);

U8 SlottByte(const U8* fec);

U32 U8AlignedU32(const U32* len);
/*
U8 SlottByte(const U8& fec);

U32 U8AlignedU32(const U32& len);
*/

#ifdef __cplusplus
}
#endif
#endif

源文件这样使用:

WORD32 DecodeR1fRNGRsp()
{
//省略部分代码……
}

WORD32 DecodeR1fSBCRsp()//编译时,这行出现错误,
错误提示:error C2275: 'WORD32' : illegal use of this type as an expression
...\commondefs.h(29) : see declaration of 'WORD32'


请问怎么解决?谢谢!


[解决办法]
定义没啥问题

WORD32是不是在这个函数体中用错了?

读书人网 >C++

热点推荐