Shop OBEX P1 Docs P2 Docs Learn Events
min / max c ode stdlib ?? Solved — Parallax Forums

min / max c ode stdlib ?? Solved

AnubispodAnubispod Posts: 42
edited 2013-04-20 10:04 in Propeller 1
Hi, i have some code that i port where they use the min max functions from c. and they should be in stdlib. but some how i get the error

thats the code i trz to port
tmp = min(abs(rcData[axis]-MIDRC),500);
C:\Users\R2D2\AppData\Local\Temp\ccFucLX0.o: In function `_annexCode':  (.text+0x48): undefined reference to `_min'
  collect2: ld returned 1 exit status
 



its a port from a Arduino code ??

Best regards
Oliver R

Edit :

have written some functions seems to work :)
int32_t  constrain(int32_t x, int32_t  a, int32_t  b) {     if(x < a) {
         return a;
     }
     else if(b < x) {
         return b;
     }
     else
         return x;
 }
 int32_t  min(int32_t  a, int32_t  b) {
     if(a < b) {
         return a;
     }
     else
         return b;
 }
 int32_t  max(int32_t  a, int32_t  b) {
     if(a > b) {
         return a;
     }
     else
         return b;
 }



Comments

  • ersmithersmith Posts: 6,054
    edited 2013-04-20 09:59
    min and max are in the standard C++ library (I think), but they are not part of the standard C library.

    If you make your versions macros, or better yet inline functions, they can be expanded inline to the appropriate Propeller instructions.

    Eric
  • ersmithersmith Posts: 6,054
    edited 2013-04-20 10:04
    min and max are in the standard C++ library (I think), but they are not part of the standard C library.

    If you make your versions macros, or better yet inline functions, they can be expanded inline to the appropriate Propeller instructions.

    Eric
Sign In or Register to comment.