Arduino: error: 'abs' was not declared in this scope

冷暖自知 提交于 2019-12-24 01:45:26

问题


I'm working on an arduino library needing the abs() function:

#include <math.h>
normTransFreq1 = abs(1.0);

Error: 'abs' was not declared in this scope

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.


回答1:


Just found the solution:

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


来源:https://stackoverflow.com/questions/15965025/arduino-error-abs-was-not-declared-in-this-scope

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!