首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

运作出错 CXX0030: Error: expression cannot be evaluated

2012-08-16 
运行出错 CXX0030: Error: expression cannot be evaluated使用一个model类读取3dmax文件,在model.h中定义

运行出错 CXX0030: Error: expression cannot be evaluated
使用一个model类读取3dmax文件,在model.h中定义了object结构体,编译没错,调试运行到出错的地方时,就出现运行出错 CXX0030: Error: expression cannot be evaluated错

误,还有这个First-chance exception in FighterTest.exe: 0xC0000005: Access Violation.什么原因?求大侠解答
class Model  
{
public:
typedef struct{
  float x,y,z;
}vertex_type;

// The polygon (triangle), 3 numbers that aim 3 vertices
typedef struct{
  unsigned short a,b,c;
}polygon_type;

// The mapcoord type, 2 texture coordinates for each vertex
typedef struct{
  float u,v;
}mapcoord_type;

// The object type
struct obj_type
{
char name[20];
   
int vertices_qty;
  int polygons_qty;

  vertex_type vertex[MAX_VERTICES]; 
  polygon_type polygon[MAX_POLYGONS];
  mapcoord_type mapcoord[MAX_VERTICES];
  //int id_texture;
};
----------------------------------------
...
}



char Model::Load3DS(char *p_filename)
{
  int i;
  FILE *l_file;
  unsigned short l_chunk_id; 
  unsigned int l_chunk_lenght; 
  unsigned char l_char; 
  unsigned short l_qty; 
  unsigned short l_face_flags; 

if ((l_file=fopen (p_filename, "rb"))== NULL) return 0; //Open the file

while (ftell (l_file) < filelength (fileno (l_file))) //Loop to scan the whole file 
{
fread (&l_chunk_id, 2, 1, l_file); //Read the chunk header
printf("ChunkID: %x\n",l_chunk_id); 
fread (&l_chunk_lenght, 4, 1, l_file); 
printf("ChunkLenght: %x\n",l_chunk_lenght);

switch (l_chunk_id)
  {

case 0x4d4d: 
break;  


case 0x3d3d:
break;


case 0x4000: 
i=0;
do
{
fread (&l_char, 1, 1, l_file);
  object->name[i]=l_char;//出错的地方
i++;
  }while(l_char != '\0' && i<20);

break;


default:
fseek(l_file, l_chunk_lenght-6, SEEK_CUR);
  } 
}
fclose (l_file); // Closes the file stream
return (1); // Returns ok
}

[解决办法]
崩溃或出现运行时错误的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处。

[解决办法]
加断点,然后F10或者F11进行跟踪,查看每一步的变量的变换

热点排行