Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not using abs() from stdlib? #82

Open
NicoHood opened this issue Sep 1, 2017 · 1 comment
Open

Why not using abs() from stdlib? #82

NicoHood opened this issue Sep 1, 2017 · 1 comment

Comments

@NicoHood
Copy link

NicoHood commented Sep 1, 2017

Why does Arduino.h use its own abs() if stdlib has this already builtin. This causes me problems in build environments. I dont see any reason why one would prefer an Arduino definition. Can we get rid of it?

#define abs(x) ((x)>0?(x):-(x))
NicoHood referenced this issue in NicoHood/FastLED Sep 1, 2017
This is required as Arduino.h #define's its own abs() makro. Outside of Arduino environments stdlib is required.
Also see: https://github.com/arduino/Arduino/issues/6684
@facchinm
Copy link
Member

facchinm commented Sep 4, 2017

To be considered for merge alongside https://github.com/arduino/Arduino/issues/6098 (I'm 👍 for both)

focalintent referenced this issue in FastLED/FastLED Nov 2, 2017
* renamed boolean to bool

* Rename byte to uint8_t

* Fix compilation error: 'NULL' was not declared in this scope

* Always typedef RoReg and RwReg for the AVR platform

* Include stdlib.h if abs() is not available
This is required as Arduino.h #define's its own abs() makro. Outside of Arduino environments stdlib is required.
Also see: https://github.com/arduino/Arduino/issues/6684

* Replace digitalWrite() with Pin Class by FastLed

* Include string.h for memset function
This include is normally done by Arduino.h but still required for makefile environments
$ grep string.h . -r
./Arduino.h:#include <string.h>

* Include math.h for pow()
math.h is normally included by Arduino.h but required for a makefile build
$ grep math.h . -r
./Arduino.h:#include <math.h>
@sandeepmistry sandeepmistry transferred this issue from arduino/Arduino Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants