title: Structure declaration scope
body: <p>I have divided my project into this source folders:</p>
  
  <pre><code>src/
  src/THREADS
  src/UKF_IMU+GPS
  src/UKF_WCT
  </code></pre>
  
  <p>I have declared the structure in this file "src/UKF_IMU+GPS/main_general.h"</p>
  
  <p><strong>main_general.h</strong></p>
  
  <pre><code>//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;
  };
  </code></pre>
  
  <p>Then, I have declared an structure global variable object in "/src/THREADS/IMUandGPS.cpp"</p>
  
  <p><strong>IMUandGPS.cpp</strong></p>
  
  <pre><code>#include "../UKF_IMU+GPS/main_general.h"
  
  /* Global variables */
  struct S_POS POS_Snapshot;
  struct S_IMU IMU_Snapshot;
  struct S_GPS GPS_Snapshot;
  </code></pre>
  
  <p>I do some stuff with the structure and it works perfect.</p>
  
  <p>I also use the same global object in the other file "/src/THREADS/Write_IMUAndGPS_OF.cpp"</p>
  
  <p><strong>Write_IMUAndGPS_OF.cpp</strong></p>
  
  <pre><code>#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;
  </code></pre>
  
  <p>I do some stuff with the structure and it works perfect as well.</p>
  
  <p>The problem comes here, I have to use the POS global structure in this file:
  "/src/src/UKF_WCT/UKF_Algorithm.cpp"</p>
  
  <p><strong>UKF_Algorithm.cpp</strong></p>
  
  <pre><code>#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;
  </code></pre>
  
  <p>Includes and everything is the same but the compiler gives me an error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>PosX,Y and Z are also double so is not type problem...Why could be this problem?</p>