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? #6684

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

Comments

3 participants
@NicoHood
Contributor

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 added a commit to NicoHood/FastLED that referenced this issue Sep 1, 2017

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: arduino/Arduino#6684
@facchinm

This comment has been minimized.

Show comment
Hide comment
@facchinm

facchinm Sep 4, 2017

Member

To be considered for merge alongside #6098 (I'm 👍 for both)

Member

facchinm commented Sep 4, 2017

To be considered for merge alongside #6098 (I'm 👍 for both)

focalintent added a commit to FastLED/FastLED that referenced this issue Nov 2, 2017

Makefile Compilation Fix (#490)
* 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: arduino/Arduino#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment