2016-06-10 2 views
0

나는이 소스 폴더로 내 프로젝트를 구분 한 :구조 선언 범위

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

나는이 파일 "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; 
}; 

다음, 나는 "/src/THREADS/IMUandGPS.cpp"의 구조를 전역 변수 객체

를 선언 한 6,

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; 

나는 구조와 몇 가지 물건을하고 그것을 완벽하게 작동합니다. 나는 또한 내가 구조와 함께 몇 가지 물건을 다른 파일에 "/src/THREADS/Write_IMUAndGPS_OF.cpp"

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; 

를 같은 전역 객체를 사용

완벽하게 작동합니다. "/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; 

:

문제는, 내가이 파일의 POS 글로벌 구조를 사용할 필요가 여기에 온다 포함하고 모든 것이 동일하지만 컴파일러에서 오류가 발생합니다.

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 및 Z도 두 배입니다. 그래서 문제가되지 않습니다 ... 왜이 문제가 될 수 있을까요?

답변

1

나는 이미 해결했습니다!

"src/UKF_WCT/main_general.h"에 다른 main_general.h 파일이있어서 컴파일러가 "/UKF_IMU+GPS/main_general.h"대신이 파일을 찾았습니다.

나는 파일 이름을 변경했으며 완벽하게 작동합니다!

+0

이 대답을 수락해야합니다. –