Reputation: 41
I am organizing my code so that and wanted to move some structure definitions to a header file then use them to declare variables in a separate c file (not main).
Header file:
#ifdef _InitSettingsGuard
#define _InitSettingsGuard
//Structure For Fault Levels
typedef struct FaultLevel{
FaultDef ThreePointThreeAux;
FaultDef Twelve;
FaultDef Five;
FaultDef ThreePointThree;
FaultDef PlusTwelveAux;
FaultDef NegTwelveAux;
}FaultLevel;
typedef struct FaultLevel{
FaultDef Test1;
FaultDef Test2;
FaultDef Test3;
}FaultLevel;
#endif
And here is my c file which I declare the variables:
#include "InitialSettings.h"
FaultLevel OneFaultLevel;
FaultLevel TwoFaultLevel;
FaultLevel ThreeLevel;
When i try to compile I am getting an error "unknown type name 'FaultLevel'" what am I doing wrong?
Upvotes: 0
Views: 55
Reputation: 400069
This:
#ifdef _InitSettingsGuard
#define _InitSettingsGuard
is wrong, the logic is inverted. You meant
#if !defined _InitSettingsGuard
or the commonly used short form
#ifndef _InitSettingsGuard
The point is to read the rest of the header if the guard symbol is not defined.
Also: there is no type called FaultLevel
declared in the header. There is only FaultDef
, so either change the usage:
FaultDef OneFaultLevel;
and so on, or change the typedef
:ed name, of course. Make up your mind. :)
Upvotes: 3