Closed
Description
Hi guys, I'm trying to implement one class for two different MCU types using conditional #include.
Is there any way to avoid error and specific files compilation (e.g. compile only a.cpp or b.cpp but not both of them)?
Arduino 1.6.7. Mac OS X El Capitan.
sketch/b.cpp.o: In function `I::test()':
sketch/b.cpp:3: multiple definition of `I::test()'
sketch/a.cpp.o:sketch/a.cpp:3: first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling.
sketch:
#if defined(__AVR_ATtiny85__)
#include "a.h"
#else
#include "b.h"
#endif
void setup() {
I i = I();
i.test();
}
void loop() {
}
a.h:
class I
{
public:
void test();
};
a.cpp
#include "a.h"
void I::test() {
return; // specific code for MCU A
}
b.h:
class I
{
public:
void test();
};
b.cpp
#include "b.h"
void I::test() {
return; // specific code for MCU B
}
Metadata
Metadata
Assignees
Labels
No labels