Bonjour
Voila j'ai écrit une fonction qui ne prend rien en argument et qui doit rendre un pointeur vers une structure objet3d, que j'ai écrite.
Voici mon code :
voici la définition du type objet3d
dans mon main.c, dans la fonction maintypedef struct {
int x;
int y;
int bool_visible;
} point2d ;
typedef struct {
float x;
float y;
float z;
} point3d;
typedef struct {
unsigned short int from;
unsigned short int to;
} arete;
typedef struct {
unsigned short nb_dots;
unsigned short int dots[MAX_DOTS];
int R,G,B;
} face;
typedef struct {
unsigned int num_sommets;
point3d sommets[MAX_SOMMETS];
point3d places[MAX_SOMMETS];
point2d projetes[MAX_SOMMETS];
unsigned int num_aretes;
arete aretes[MAX_ARETES];
unsigned int num_faces;
face faces[MAX_FACES];
float angleX;
float angleY;
float angleZ;
float TransMatrix[3][1];
} objet3d;
dans mon objects.hobjet3d *test = NULL;
test = make_cube(20.,20.,20.,20.,RGBToInt(0,200,0),20.,20.,20.);
et dans mon objects.cobjet3d * make_cube(float size, float x, float y, float z, int color, float rotX, float rotY, float rotZ);
objet3d * make_cube(float size, float x, float y, float z, int color, float rotX, float rotY, float rotZ)
{
objet3d* obj = NULL;
obj = (objet3d *) malloc(sizeof(objet3d));
obj->angleX = rotX;
obj->angleY = rotY;
obj->angleZ = rotZ;
obj->TransMatrix[0][0] = x;
obj->TransMatrix[1][0] = y;
obj->TransMatrix[2][0] = z;
obj->num_aretes = 12;
obj->num_faces = 6;
obj->num_sommets = 8;
obj->sommets[] = { {-size,-size,-size}, {size,-size,-size}, {-size,size,-size}, {size,size,-size},
{-size,-size,size}, {size,-size,size}, {-size,size,size}, {size,size,size} };
return obj;
}
A la compilation 'Compile', ca passe bien, par contre au 'Build', VC++ me crache 17 erreur et 1 warning :
--------------------Configuration: cube - Win32 Debug--------------------
Compiling...
objects.c
G:\wam\C\tinyPTC\3d\cube\objects.c(9) : error C2143: syntax error : missing '{' before '*'
G:\wam\C\tinyPTC\3d\cube\objects.c(11) : error C2065: 'objet3d' : undeclared identifier
G:\wam\C\tinyPTC\3d\cube\objects.c(11) : error C2065: 'obj' : undeclared identifier
G:\wam\C\tinyPTC\3d\cube\objects.c(11) : error C2065: 'NULL' : undeclared identifier
G:\wam\C\tinyPTC\3d\cube\objects.c(11) : error C2106: '=' : left operand must be l-value
G:\wam\C\tinyPTC\3d\cube\objects.c(12) : error C2059: syntax error : ')'
G:\wam\C\tinyPTC\3d\cube\objects.c(15) : error C2223: left of '->angleX' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(16) : error C2223: left of '->angleY' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(17) : error C2223: left of '->angleZ' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(19) : error C2223: left of '->TransMatrix' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(20) : error C2223: left of '->TransMatrix' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(21) : error C2223: left of '->TransMatrix' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(23) : error C2223: left of '->num_aretes' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(24) : error C2223: left of '->num_faces' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(25) : error C2223: left of '->num_sommets' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(27) : error C2223: left of '->sommets' must point to struct/union
G:\wam\C\tinyPTC\3d\cube\objects.c(27) : error C2059: syntax error : ']'
G:\wam\C\tinyPTC\3d\cube\objects.c(30) : warning C4047: 'return' : 'int *' differs in levels of indirection from 'int '
Error executing cl.exe.
cube.exe - 17 error(s), 1 warning(s)
Auriez-vous une idée pour corriger ce pb ? (la ligne 9 de objects.c est celle qui contient le typage de make_cube)
merci
Partager