I recently made a library with a class that uses an array of function pointers for a finite state machine. When I compiled with a sketch that just includes the header and does nothing else, I get this error that says all the class methods were defined multiple times:
States/states.cpp.o: In function states::runstate()': /Users/me/Documents/Arduino/libraries/StateMachine/states.cpp:28: multiple definition of
states::runstate()'
states.cpp.o:states.cpp:28: first defined here
States/states.cpp.o: In function states::addstate(void (*)())': /Users/me/Documents/Arduino/libraries/States/states.cpp:36: multiple definition of
States::addstate(void (*)())'
states.cpp.o:states.cpp:36: first defined here
States/states.cpp.o: In function States': /Users/me/Documents/Arduino/libraries/States/states.cpp:16: multiple definition of
States::States(short)'
states.cpp.o:states.cpp:16: first defined here
States/states.cpp.o: In function States': /Users/kenjitimmerman/Documents/Arduino/libraries/States/states.cpp:16: multiple definition of
States::States(short)'
arduinos.cpp.o:arduinos.cpp:16: first defined here
My header only declares the methods like "int foo()" and the .cpp file has only one definition for each function. I've used preprocessor to protect the header from multiple inclusions. When I searched for errors like this, all the time they had actually been defined multiple times. Could anyone explain what the problem is?