I am trying to use separate files for my PlatformIO Arduino project, but I get this error:
.pio/build/uno/src/test.cpp.o (symbol from plugin): In function `value':
(.text+0x0): multiple definition of `value'
.pio/build/uno/src/main.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
To me this error sounds like the one you would get if you don't have include guards or use pragma once, but they didn't solve my problem.
This is my main.cpp:
#include <Arduino.h>
#include "test.hpp"
void setup() {
Serial.begin(115200);
Serial.println(value);
}
void loop() {
}
test.hpp:
#ifndef TEST_HPP
#define TEST_HPP
int value = 3;
#endif
The test.cpp just includes the test.hpp and does nothing else.