This is an Arduino project compiled in Visual Studio (using visual micro plugin). I am getting the following error:
AutonomyHandler.cpp.o (symbol from plugin): In function AutonomyHandler::setup() const (.text+0x0): multiple definition of Module::AvailableCommandKeys ArduinoProject.cpp.o (symbol from plugin)*: (.text+0x0): first defined here
I am using an enum of CmdKeys within the class definition, and I can use the line of code below to get the available set of keys, but when I try to use it, I get multiple compile errors as seen above for each place I have used it.
Module::AvailableCommandKeys
My Module.h looks as follows:
#ifndef _MODULE_h
#define _MODULE_h
class Module {
public:
enum CmdKeys { Forward, Left, Back, Right, Stop };
static const CmdKeys AvailableCommandKeys[2];
// other definitions...
};
const Module::CmdKeys Module::AvailableCommandKeys[] = { Forward, Back };
#endif
Does anyone know what is happening? I have had this issue before and making the members non-static fixed the issue but I want to keep these enum arrays static.
const Module::CmdKeys Module::AvailableCommandKeys[] = { Forward, Back };to a .cpp file. Otherwise, every cpp file that#incluides Module.h will have a definition ofModule::AvailableCommandKeys. - R Sahu;after class declaration - Killzone Kid_MODULE_h) and names that contain two consecutive underscores are reserved for use by the implementation. Don’t use them in your code. - Pete Becker