2016-02-16 06:49 AM
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?2016-02-16 08:24 AM
2016-02-16 01:15 PM
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))
2016-02-17 01:46 AM
Thanks,
I got it I tried the macros. They are OK. Using fmax()/fmin() is not soo good because of floating calculations.2016-02-17 01:48 AM