Hi,
I am trying to build a little big project in arduino. so I devide in to one .ino, several .cpp and .h
if I typedef a struct in one of the .h file.
How should I used it in other .cpp or .h file?
in dataManagement.h
typedef struct
{
uint8_t memIndex;
XBeeAddress64 addr64Node;
bool isActive;
deviceType_t sensorType;
messageType_t messageType;
sensorData_t valueReceive;
messageProfix_t weChatProfix;
}sensorControlStruct_t;
dataManagement.cpp
sensorControlStruct_t dataBuffer[sensor_MEM_NA]={xxxx};
I want to use it in RF.h
extern sensorControlStruct_t dataBuffer[sensor_MEM_NA];
so always have this
error: 'sensorControlStruct_t' does not name a type
Thanks a lot.
The definition of sensorControlStruct_t is missing in the RF.h. You have to include the dataManagement.h into RF.h.
Do not forget conditional definition in the dataManagement.h (e.g. #ifdef dataManagement_h - #endif) otherwise it can fall to another error: multiply defined sensorControlStruct_t.
Thanks for your reply。
I did it but still does not work.
#ifndef RF_h
#define RF_h
#include <arduino.h>
#include "dataManagement.h"
extern sensorControlStruct_t dataBuffer[sensor_MEM_NA];
#endif
#ifndef dataManagement_h
#define dataManagement_h
#include <arduino.h>
typedef struct
{
xxxx
}sensorControlStruct_t;
#endif
I find out that I included RF.h in dataManagement.h as well
remove it, it works now.
what is the problem with that_
It is recursive definition dataManagement.h -> RF.h -> ... and since there is condition for whole header, it is skipped after first use.
Thanks very much for you help.
have a nice day!