Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Gcc Error

Started by rougetaal Mar 18, 2012 at 1:04 PM 0 replies 1.7k views
Original Post
rougetaal
rougetaal
Hello, I have a problem when I try to compile two c-files vector.c et son header vector.h et matrix.c matrix.h

vector.h
#ifndef VECTOR_H
#define VECTOR_H
#include <math.h>
#include "matrix.h"
typedef struct vector3_s
{
float x, y, z;
}vector3;
vector3 vec3_add(vector3*, vector3*);
vector3 vec3_sub(vector3*, vector3*);
vector3 vec3_mul(vector3*, float);
float vec3_length(vector3*);
vector3 vec3_normalize(vector3*);
float vec3_dot(vector3*, vector3*);
vector3 vec3_cross(vector3*, vector3*);
vector3 vec3_translate(vector3*, matrix4x4*);
#endif


matrix.h
#ifndef MATRIX_H
#define MATRIX_H
#include "vector.h"
typedef struct matrix4x4_s
{
float m[4][4];
}matrix4x4;
matrix4x4 mat_set(float, float, float, float,
float, float, float, float,
float, float, float, float,
float, float, float, float);

matrix4x4 mat_zero();
matrix4x4 mat_identity();

matrix4x4 mat_mul(matrix4x4*, matrix4x4*);
matrix4x4 mat_translate(matrix4x4*, vector3*);
matrix4x4 mat_rotate(matrix4x4*, vector3*);
matrix4x4 mat_scale(matrix4x4*, vector3*);
#endif


I compile with gcc -std=c99 -c vector.c matrix.c

it gives me this error message:

[bquote]In file included from vector.h:6:0,
from vector.c:1:
matrix.h:21:37: erreur: unknown type name 'vector3'
matrix.h:22:34: erreur: unknown type name 'vector3'
matrix.h:23:33: erreur: unknown type name 'vector3'
In file included from matrix.h:4:0,
from matrix.c:1:
vector.h:23:34: erreur: unknown type name 'matrix4x4'[/bquote]

can you help me please.
Bregma
Bregma
You have a cicular include file dependency. The solution is to use forward declarations of your dependent classes.
Stephen M. Webb
Professional Free Software Developer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.