KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Today I encountered a weird problem when trying to use IRremote library, and I managed to strip down the problem as following. If you have a folder in libraries, with Foo.h and Foo.cpp inside, and write a sketch to include 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(){ } The error message is: 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'm using a Windows 7 32-bit machine. Tested on Arduino 1.0.5, 1.0.4, and 21, 22. So with some research I figured out the problem comes from my confusion of preprocessor and linking. This question explains how preprocessor includes file and include guard: In C++ why have header files and cpp files? These are some of the pages helped me understand linking: 1.8 — Programs with multiple files GCC and Make - A Tutorial on how to compile, link and build C/C++ applications Guide: Multiple sources And this is a better explanation of inline specifier: <a href="htt
Tags (comma-separated)
Save Edits
Cancel