I have a class where I am trying to define several static/const objects of a custom type. The header file looks roughly like this:
#ifndef SRC_TEMPCONT_HXX
#define SRC_TEMPCONT_HXX
class TC
{
public:
// ... misc stuff ...
class Register
{
public:
//... misc stuff ...
enum Access { Read=0x1, Write=0x2, ReadWrite=0x3 };
//constructor
Register(uint16_t address, Access access, size_t size);
//series of static variables
static Register
Setpoint1, SetpointSafetyCheck, Temperature,
SecurityByte, RampByte, DisplayByte, DisplayState, Model,
CommAddress, CommBaud, CommDataType, CommDebug,
ProgramRun,
Input, Unit,
SoftwareVersion,
MaxProgram, Program;
};
};
#endif //TEMPCONT_HXX
In the cxx file I instantiate the variables like this:
TC::Register TC::Register::Setpoint1 (0x007F, ReadWrite, 2);
TC::Register TC::Register::SetpointSafetyCheck (0x0125, ReadWrite, 1);
TC::Register TC::Register::Temperature (0x001C, Read, 2);
//etc...
My makefile compiles with the following command which I believe is correct:
g++ -g -Wall -DOS_LINUX -g -lm -lz -lutil -lnsl -lpthread -lrt -Isrc -I/home/deap/ovendaq/midas/include -I/home/deap/ovendaq/midas/drivers/divers src/obj/cont_test.o src/obj/TempCont.o src/obj/TimeoutSerial.o -L/home/deap/ovendaq/midas/linux-m64/lib -lmidas -lboost_system -lboost_program_options -o bin/cont_test.exe
But I am getting this bizarre error for each variable:
src/obj/TempCont.o:/usr/include/boost/noncopyable.hpp:24: multiple definition of `TC::Register::Setpoint1'
src/obj/cont_test.o:/home/deap/dev/OvenProject/src/cont_test.cxx:14: first defined here
src/obj/TempCont.o:/usr/include/boost/system/error_code.hpp:350: multiple definition of `TC::Register::SetpointSafetyCheck'
src/obj/cont_test.o:/home/deap/dev/OvenProject/src/cont_test.cxx:16: first defined here
src/obj/TempCont.o:/usr/include/boost/exception/exception.hpp:344: multiple definition of `TC::Register::Temperature'
src/obj/cont_test.o:/home/deap/dev/OvenProject/src/cont_test.cxx:18: first defined here
//etc...
Why does it seem to think I am declaring the variables within the boost libraries? I have tested this exact same structure in a simplified program and it worked properly, but I can't figure out why it's not working here. What am I doing wrong?
TIA
.o
files wasn't recompiled in a while (perhaps due to a problem in the Makefile)? Or something funny you do inTempCont.o
-- you didn't say much about that file.