This code is compiling and functioning properly on a different environment in C using gcc. I am in the process of porting it into a new C++ environment using g++ and getting a redefinition error.
I've seen similar issues, but my problem might stem from the fact that I've got predeclarations in the struct definitions and need to predeclare again in the instantiation. Here is the relevant code:
transaction.h
...
typedef int ( *pfnTrans)(transaction *);
typedef struct tag_TRANSTEP transStep; //forward declare this for the following struct.
typedef struct tag_RETURNMAP
{
int onThisReturn;
transStep * runThis;
}returnMap;
#define MAX_BRANCHES 10
struct tag_TRANSTEP
{
pfnTrans thisStepsFunction;
returnMap retMap[MAX_BRANCHES];
};
...
source.cpp
...
//Forward declaring the steps, since they reference one another.
transStep tsConsultChoreList;
transStep tsPayBills;
transStep tsMowLawn;
transStep tsFixLawnMower;
transStep tsConsultChoreList = {fnConsultChoreList, {{MOW_LAWN, &tsMowLawn},
{PAY_BILLS, &tsPayBills},
{0, NULL}}}; // this entry signifies end of returnMap
transStep tsPayBills= {fnPayBills, {{SUCCESS, &fnConsultChoreList},
{0, NULL}}}; // this entry signifies end of returnMap
transStep tsMowLawn= {fnMowLawn, {{SUCCESS, &tsConsultChoreList},
{FIX_MOWER, &tsFixLawnMower},
{0, NULL}}}; // this entry signifies end of returnMap
transStep tsFixLawnMower= {fnFixLawnMower, {{SUCCESS, &tsMowLawn},
{0, NULL}}}; // this entry signifies end of returnMap
...
I'm not getting any errors from the .h file, but for each transStep in the .cpp I am getting a "redefinition of ..." error and an accompanying "... previously declared here" error.