One error, one question

Started by
1 comment, last by pauljg 22 years, 1 month ago
Help ! I''ve got this one error in my program that I just cant seem to understand, here''s the error: ANSI C++ forbids implicit conversion from ''void *'' in assignment And here''s the line that creates the error: p->verts = malloc (sizeof (vec3_t) * p->numvertex); It must be the way I''m trying to call malloc, but I''ve no idea what to do about it. If it helps I''m using dev-c (mingw) Thanks.
Advertisement
quote:Original post by pauljg
And here''s the line that creates the error:

p->verts = malloc (sizeof (vec3_t) * p->numvertex);


seems ok to me, just one little nuance:

p->verts = (vec3_t *)malloc (sizeof (vec3_t) * p->numvertex);

this ought to fix the problem


"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
C++ tightens the type-checking required over and above that of C. malloc returns a void*. In C, you can implicitly cast void* to any other type. In C++ you must make the cast explicit.

This topic is closed to new replies.

Advertisement