illegal use of this type as an expression我定义了一个结构体typedef struct{int xint yU16 itemImage
illegal use of this type as an expression
我定义了一个结构体
typedef struct
{
int x;
int y;
U16 itemImageId;
U16 checkId;
U16 checkedId;
int index;
char str[50];
}MY_MenuDC;
然后使用他
MY_MenuDC *MenuDC = (MY_MenuDC*)malloc(sizeof(MY_MenuDC));
结果编译报错
E:\prj_mt6235\plutommi\mmi\myapp\myappsrc\myappsrc.c(140) : error C2275: 'MY_MenuDC' : illegal use of this type as an expression
E:\prj_mt6235\plutommi\mmi\myapp\myappsrc\myappsrc.c(113) : see declaration of 'MY_MenuDC'
E:\prj_mt6235\plutommi\mmi\myapp\myappsrc\myappsrc.c(140) : error C2065: 'MenuDC' : undeclared identifier
[解决办法]
- C/C++ code
#include<stdio.h>#include <stdlib.h>#define U16 unsigned short void main(){ typedef struct { int x; int y; U16 itemImageId; U16 checkId; U16 checkedId; int index; char str[50]; }MY_MenuDC; //然后使用他 MY_MenuDC *MenuDC = (MY_MenuDC*)malloc(sizeof(MY_MenuDC));} 