c - 阿杜诺 C : undefined reference to `readArms()'

标签 c function arduino

在编译一些 Arduino C 文件时出现错误“对 `readArms()' 的 undefined reference ”

代码可以在 paste bin 上找到.

但基本上发生的是:

在我使用的 INO 文件中:

readArms();

在“armfunctions.h”和“armfunctions.c”中声明

.h文件包含

void readArms(void);

还有 .c 文件:

void readArms(void){
    float motor1 = 0.0;
    int motor = 0;
    motor = analogRead(READMOTOR1);
    motor1 = (float)motor;
    motor1 = (motor1 - 87.0) * (400.0/(1007.0-87.0));
    delay(1000);
}

最佳答案

我今天已经为此研究了几个小时,制作并测试了各种草图,并且发现(正如您已经发现的那样)将它们更改为 .cpp 是一种解决方法,但如果您想专门创建一个 c 文件,您必须将原型(prototype)包装在 header 中才能使其编译。有一些关于它的好帖子,但问题的症结在于你的 .h 文件中:

#ifdef __cplusplus
extern "C" {
#endif

void readArms(void);

#ifdef __cplusplus
}
#endif

关于c - 阿杜诺 C : undefined reference to `readArms()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19635007/

相关文章:

R 列用数据框中的其他列替换字母表

arduino - 评估一个值是增加还是减少(arduino)

c - Arduino Due C 定时器编码(中断计数)

c - 如何在linux中添加graphviz库?

C中的打印函数mutex无法正常工作

c - 为什么这个简单的 C 程序会出现段错误?

javascript - 使用 javascript 在对象中创建函数

c - 终端模拟器中的随机字符

function - Haskell 检查空列表

ruby - Arduino POST ERROR 错误请求行 `'