Hi all,
I'm an assembler/C programmer who has to convert my code over to run on C++, so with hope in my heart I changed my makefile gcc to g++. Surprisingly most seemed to compile OK, except for a series of errors all related to similar function calls, the errors are all like
common/ModelLoader.c: In function ‘void LoadLights(FILE*, MODEL*)’:
common/ModelLoader.c:116: error: invalid conversion from ‘void*’ to ‘light*’
and relate to mallocing structures inside structures
so the above error is produced from the line
model->number_of_lights=number_of_lights;
model->light = malloc (sizeof (LIGHT) * number_of_lights); THIS IS LINE 116
Can anyone advise what I need to do to make this run in C++ (g++)
I'm using etch and g++ 4.1.1 if that matters.
my C structure is
typedef struct model
{
int number_of_materials;
struct texture *material; /*list of materials used */
struct camera *camera; /*model cameras */
int number_of_lights;
struct light *light; /*light numbers positions etc*/
.....
which uses a structure
typedef struct light
{
float pos[3];
float lookat[3];
float ambient[4];
float diffuse[4];
float specular[4];
uint spotlight;
GLuint lightid;
}LIGHT;
I'm I allowed to use structures inside structures in C++.
Thanks in advance