Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pinguino 12 - min macro in sdcc
29-06-2016, 09:40 PM,
#1
Pinguino 12 - min macro in sdcc
When getting a compiler  error on min(var, var2), which compiled in Pinguino 11, I found that in macro.h the min and max macro is commented out.


Code:
    //#ifndef __XC8__
        //#define min(a,b)            ((a)<(b)?(a):(b))
        //#define min(x, y)           (y ^ ((x ^ y) & -(x < y)))
        //#define max(a,b)            ((a)>(b)?(a):(b))
        //#define max(x, y)           (x ^ ((x ^ y) & -(x < y)))
    //#endif

After changing this to


Code:
    //#ifndef __XC8__
        #define min(a,b)            ((a)<(b)?(a):(b))
        //#define min(x, y)           (y ^ ((x ^ y) & -(x < y)))
        #define max(a,b)            ((a)>(b)?(a):(b))
        //#define max(x, y)           (x ^ ((x ^ y) & -(x < y)))
    //#endif

like it is in the macro.h of version 11 the sketch compiles without errors.

Is this a regression or did I mis something obvious?

btw, I like the Pinguino IDE 12 very much.

Thanks for all the good work, Dick
Reply
30-06-2016, 08:46 AM,
#2
RE: Pinguino 12 - min macro in sdcc
Hello Dick,
There is obviously a mistake. You are right by coming back to the uncommented definitions version 11.
André
Reply
30-06-2016, 08:24 PM,
#3
Smile  RE: Pinguino 12 - min macro in sdcc
Oops....  and of course the double slashes have to be removed before the #ifndef __XC8__ and #endif
to prevent errors when compiling with the xc8 compiler. [Image: smile.gif]


Code:
    #ifndef __XC8__
       #define min(a,b)            ((a)<(b)?(a):(b))
       //#define min(x, y)           (y ^ ((x ^ y) & -(x < y)))
       #define max(a,b)            ((a)>(b)?(a):(b))
       //#define max(x, y)           (x ^ ((x ^ y) & -(x < y)))
   #endif
Reply
30-06-2016, 10:17 PM,
#4
RE: Pinguino 12 - min macro in sdcc
Hello Dick,
I don't agree !
You have to let // before #ifndef  __XC8__ and #endif because the definitions for min and max are correct for SDCC and XC8

But simply the better thing to do is to delete the //#ifndef ... and //#endif
André
Reply
03-07-2016, 01:36 PM,
#5
RE: Pinguino 12 - min macro in sdcc
Hello Andre,

If the min and max macro's are enabled in a XC8 compilation the compiler will give a redefine warning.
The XC8 compiler has min and max macro's defines in stdlib.h and they do the same as min/max in Pinguino's macro.h.
So it's not a problem to keep the #ifndef __XC8__ commented out but it will give a redefine warning which may confuse people.
I hope you can agree with this.

Dick.
Reply
03-07-2016, 04:52 PM,
#6
RE: Pinguino 12 - min macro in sdcc
Hello Dick,
Sorry ! I did not know with regard to XC8 the min and max functions were already defined in stdlib.h.
Many thanks for this information. So I modify my macro.h.
André
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)