【发布时间】:2021-05-22 16:47:34
【问题描述】:
我正在尝试为我的 PlatformIO Arduino 项目使用单独的文件,但出现此错误:
.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
对我来说,如果您没有包含保护或使用 pragma 一次,则此错误听起来像是您会遇到的错误,但它们并没有解决我的问题。
这是我的 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
test.cpp 只包含 test.hpp,不做其他任何事情。
【问题讨论】:
标签: c++ arduino platformio