I work on a project which contains both c
source files and c++
ones.
I use code like :
extern "C"
{
#include "init.h"
#include "ParameterGet.h"//ParameterGet.c exists
}
to include c files.
But I got a .h
files of c which has no .c
file.
And it causes(as I think) many errors of :
multiple definition of `PeriodicFaultReport'
multiple definition of `FaultActiveEventReport'
multiple definition of `FaultInactiveEventReport'
multiple definition of `FaultLatchEventReport'
where PeriodicFaultReport
,FaultActiveEventReport
,FaultInactiveEventReport
,FaultLatchEventReport
are all declared in "DataStruct.h"
and this file has no .c
file with it.
Besides I notice that PeriodicFaultReport
,FaultActiveEventReport
,FaultInactiveEventReport
,FaultLatchEventReport
are all global variables
.
[IMPORTANT]
Content relative in "DataStruct.h"
of c
:
struct OptionalString PeriodicFaultReport;
struct FaultActiveEventReportSet
{
BOOL Flag;
UINT8 Type ;
UINT32 Length;
struct Optional... Report...[2];
}FaultActiveEventReport;
struct FaultInactiveEventReportSet
{
BOOL Flag;
UINT8 Type ;
UINT32 Length ;
struct Optional... Faultt...;
}FaultInactiveEventReport;
struct FaultLatchEventReportSet
{
BOOL Flag;
UINT8 Type ;
UINT32 Length ;
struct OptionalInteger FaultID[2];
}FaultLatchEventReport;
I know there may be an answer like here
But it is not right:
I get all the files from a c
project, and there, "DataStruct.h"
are included multiple times in other .h files, and it has no problem.
(The c
project is in VS2008
, which may be the reason of no problems)
But Is this true, VS
helps to this and break the c
standard?