2016-06-10 9 views
0

Ich habe mein Projekt in diese Quelle Ordner unterteilt:Strukturdeklaration Umfang

src/ 
src/THREADS 
src/UKF_IMU+GPS 
src/UKF_WCT 

Ich habe die Struktur in dieser Datei deklariert "src/UKF_IMU + GPS/main_general.h"

main_general.h

//Structure Declarations 
struct FD 
{ 
int IMU, GPS; 
}; 

struct S_POS 
{ 
double X=0, Y=0, Z=0; 
double Latitude=0, Longitude=0, Altitude=0; 
}; 

struct S_IMU 
{ 
double ACCX=0, ACCY=0, ACCZ=0, GYRX=0, GYRY=0, GYRZ=0; 
double ACCX_Bias=0, ACCY_Bias=0, ACCZ_Bias=1, GYRX_Bias=0, GYRY_Bias=0, GYRZ_Bias=0; 
double Pitch=0, Roll=0, Yaw=0; 

//Variables to Calculate AT 
double AT=0; 
unsigned int Time=0; 
}; 

struct S_GPS 
{ 
int Date=0, TimeHour=0, NumSatUsed=0; 

double Yaw=0, Velocity, Vel_X=0, Vel_Y=0, Vel_Z=0; 
double Std_Dev_Lat=0, Std_Dev_Lon=0, Std_Dev_Alt=0; 
double HDOP=0; 

//Variables to Calculate AT 
double AT=0; 
unsigned int Time=0; 
}; 

Dann habe ich eine Struktur globale Variablenobjekt in „/src/THREADS/IMUandGPS.cpp“

012.351 erklärt

IMUandGPS.cpp

#include "../UKF_IMU+GPS/main_general.h" 

/* Global variables */ 
struct S_POS POS_Snapshot; 
struct S_IMU IMU_Snapshot; 
struct S_GPS GPS_Snapshot; 

ich ein paar Sachen mit der Struktur und es funktioniert perfekt.

ich auch das gleiche globale Objekt in der anderen Datei "/src/THREADS/Write_IMUAndGPS_OF.cpp" verwenden

Write_IMUAndGPS_OF.cpp

#include "../UKF_IMU+GPS/main_general.h" 

/* External Global variables */ 
extern struct S_POS POS_Snapshot; 
extern struct S_IMU IMU_Snapshot; 
extern struct S_GPS GPS_Snapshot; 

ich ein paar Sachen mit der Struktur und es funktioniert auch perfekt.

Das Problem kommt hier, ich habe die POS globale Struktur in dieser Datei verwenden: "/src/src/UKF_WCT/UKF_Algorithm.cpp"

UKF_Algorithm.cpp

#include "../UKF_IMU+GPS/main_general.h" 

/* External Global variables */ 
extern struct S_POS POS_Snapshot; 

PosX = POS_Snapshot.Latitude; 
PosY = POS_Snapshot.Longitude; 
PosZ = POS_Snapshot.Altitude; 

Includes und alles ist das gleiche, aber der Compiler gibt mir einen Fehler:

forward declaration of 'struct S_POS' UKF_Algorithm.cpp 
invalid use of incomplete type 'struct S_POS' UKF_Algorithm.cpp 
invalid use of incomplete type 'struct S_POS' UKF_Algorithm.cpp 
invalid use of incomplete type 'struct S_POS' UKF_Algorithm.cpp 

PosX, Y und Z sind auch doppelt Also ist kein Typ Problem ... Warum könnte dieses Problem sein?

Antwort

1

Ich habe es schon gelöst!

Das Problem war, dass ich eine andere Datei main_general.h in "src/UKF_WCT/main_general.h" hatte, so dass der Compiler diese Datei anstelle von "/UKF_IMU+GPS/main_general.h" fand.

Ich habe den Namen der Datei geändert und es funktioniert perfekt!

+0

Sie sollten diese Antwort akzeptieren. –