I just don't get the problem with this very simple code... I'm despairing.
testLib.h
#ifndef testLib
#define testLib
int mal2(int wert); // works properly
int abc; // throws: multiple definition of `abc'
#endif
testLib.cpp
#include "testLib.h"
int mal2(int wert) {
return wert*2;
}
main.ino
#include <testLib.h>
int ergebnis = mal2(5);
// int abc; // throws: error: redefinition of 'int abc'
// abc = 1; // throws: error: 'abc' does not name a type
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Why is abc
multiple defined if I don't use it in main.ino - shouldn't #ifndef
prevent exactly that? If it is already multiple defined, why can't I use one of the other two lines then?
Thanks in advance for any light you bring into my darkness...!