View Full Version : Runtime error R6002?

05-19-2001, 06:19 PM
Help! I'm writing a 3d file loader and I keep getting this error when I test my program:

runtime error R6002
-floating point not loaded

What does this mean? How can I fix it?

Here is the section of code that I think is causing this error:

typedef struct
char Name[16], Author[32], Info[256], *MatName;
float Radius3do;
int maxvert, maxtri, maxmesh, maxmat, *mat_w, *mat_h;
Mesh_t *Mesh;

Model_t *Model;
Model = (Model_t *) malloc(sizeof(Model_t));

sscanf (readline, "RADIUS %f", &Model->Mesh[jcount].Radius);

[This message has been edited by Zy (edited 05-19-2001).]

05-20-2001, 02:30 AM
Did you allocate memory for Mesh?

05-20-2001, 08:06 AM
Doesn't Model = (Model_t *) malloc(sizeof(Model_t)); allocate memory for the mesh.

The funny thing is that the whole program works when I leave a bunch of fprintf's (for program feedback) in the program. But when I comment some of them out, I start to get that error R6002 message and the program crashes.

05-20-2001, 08:43 AM
no malloc does not allocate the memory for mesh. It just allocates the memory for a pointer to a mesh. (4 bytes) you have to created a new mesh yourself

05-20-2001, 02:25 PM
As far as R6002 goes I believe your compiler (VC?) optimized out the library (I think).

Try adding a line like this early in the program

float ignoreMe;
ignoreMe = 123.456f;
Any floating point number will do. The presence of a floating point number should force VC to link in the necssary library.
Technically a pointer is not necessarily 4bytes because it will change depending on the model you've choosen to build with and the platform you're working on.
From your structure it looks like memory also needs to be allocated for MatName, mat_w and mat_h in addition to Mesh after allocating for Model.
You may want to create a function to do all the allocations and another function just to deallocate all the memory in reverse order to keep the code a little cleaner.

[This message has been edited by Frumpy (edited 05-20-2001).]

05-20-2001, 06:22 PM
Does this really work?

float ignoreMe;
ignoreMe = 123.456f;

Sounds strange that I have to fool VC++ to use the correct libraries.

As for memory allocation for MatName, mat_w, and mat_h...yes I do allocate memory for these vars further in the code. I didn't list them because I was only getting errors with the Radius part.

05-21-2001, 06:36 AM
A long time ago I did once receive runtime error R6002 while loading data from a text file just as you've done and inserting those two lines of code solved the problem.

You're giving VC a reason to link in the floating point library more than you are fooling VC.