Archived

This topic is now archived and is closed to further replies.

One error, one question

This topic is 5745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites