Using math.h
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-16 6:49 AM
Posted on February 16, 2016 at 15:49
Hello every one
I need to implement the code for STM32F, like the next lines: #include <stdlib.h> #include <math.h> ... int b; a= max(10, b) The compilation result is warning: implicit declaration of function 'max' [-Wimplicit-function-declaration] linking with -lm (or libm): undefined reference to `max' So... what is a problem here with using min/ max function?
This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-16 8:24 AM
Posted on February 16, 2016 at 17:24 Hello, How about fmax()? AFAIK, max() isn't a standard function. Cheers, Mark
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-16 1:15 PM
Posted on February 16, 2016 at 22:15
max() isn't a standard function.
Correct, though it is prevalent on Microsoft platforms as a macro in stdlib.h, it uses a lower case form, but I'm not a stickler for upper case macros. I just use these when I'm on more general or UNIX/LINUX platforms#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-17 1:46 AM
Posted on February 17, 2016 at 10:46
Thanks,
I got it I tried the macros. They are OK. Using fmax()/fmin() is not soo good because of floating calculations.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-17 1:48 AM
Posted on February 17, 2016 at 10:48
