我已經分了我的項目到這個源文件夾:結構聲明範圍
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」 的結構,全局變量對象
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;
我做一些東西的結構和它作品也很完美。
問題就來了這裏,我必須使用POS全球結構在這個文件中: 「/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;
包括和一切都一樣,但編譯器給我一個錯誤:
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也是雙倍所以不是類型問題...爲什麼可能是這個問題?
你應該接受這個答案。 – 2016-08-15 22:32:44