I have a struct like this in “parser.h”
struct obj{
char *filename;
unsigned long nverts;
unsigned long curvert;
double (*verts)[3];
unsigned int *faces[3];
};
typedef obj obj;
and in parser.cpp
I am declaring
obj objmesh;
objmesh.filename="c://temp//wings.obj";
objmesh.nverts = 20;
objmesh.verts = (double (*)[3]) malloc( objmesh.nverts * sizeof(double[3]) );
objmesh.curvert = 0;
When I do these assigments at the top of the parser.cpp I get “‘objmesh’ does not name a type” error.
But when I put all these assignments in a function in parser.cpp (while obj objmesh; has global scope) , I get no error and compiles fine.
Can anyone think of a reason why that is the case? I am using Mingw Gnu 4.6 C++ compiler
You need your assignments inside a function, e.g:
By the way:
double (*)[3])begs for a typedef…