Arduino:错误:“abs"未在此范围内声明 [英] Arduino: error: 'abs' was not declared in this scope
本文介绍了Arduino:错误:“abs"未在此范围内声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个需要 abs() 函数的 arduino 库:
I'm working on an arduino library needing the abs() function:
#include <math.h>
normTransFreq1 = abs(1.0);
错误:'abs' 未在此范围内声明
Error: 'abs' was not declared in this scope
由于 math.h
已经包含在 cpp 中,我完全不确定如何解决这个问题.新安装的 arduino 1.5.2 没有帮助.
As math.h
is already included in the cpp I'm entirely unsure how to fix this problem. A new install of arduino 1.5.2 didn't help.
推荐答案
刚刚找到解决方案:
库不需要包含 math.h.相反,应该通过在头文件中添加以下内容来包含 Arduino.h:
Including math.h is not needed for the library. Instead, Arduino.h should be included by adding the following to the header file:
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
这篇关于Arduino:错误:“abs"未在此范围内声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文