Today I ran into some strange problem while trying to use the IRremote library, and I was able to fix the problem as follows. If you have a folder in the libraries, with Foo.h and Foo.cpp inside, and write sketch to enable Foo.h:
foo.h
#ifndef Foo_H #define Foo_H int AAA() { return 0; } #endif
foo.cpp
#include "Foo.h"
Sketch
#include <Foo.h> void setup(){ } void loop(){ }
Error message:
Foo\Foo.cpp.o: In function `AAA()': E:\workShop\Arduino\libraries\Foo\/Foo.h:5: multiple definition of `AAA()' includeTest.cpp.o:E:\workShop\Arduino\libraries\Foo/Foo.h:5: first defined here
I am using a 32-bit Windows 7 machine. Tested on Arduino 1.0.5, 1.0.4 and 21, 22.
So, with some research, I realized that the problem is due to my preprocessor confusion and binding. This question explains how the preprocessor includes a file and includes security:
Here are some of the pages that helped me understand:
And this is the best explanation of the built-in specifier:
source share