We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, I defined a macro as
#define min(a,b) (((a) < (b)) ? (a) : (b))
xfr_cnt = min(to_xfer, secsize - boff);
xfr_cnt= ((to_xfer < (secsize - boff)) ? (to_xfer) : (secsize - boff));
It's okay if I write that as
xfr_cnt = min(to_xfer, (secsize - boff));
Did it give an error message?
No, it's a Windows XP error dialog box. I can continue, but seems the C file is not compiled anyway.
Best send a report to Keil in that case.
I tried the code snippets, that you have posted with the C51 V7.20. The macro is expanded like yours and the object file is generated correctly. There must be anything special that you do in your code.
#define min(a,b) (((a) < (b)) ? (a) : (b)) void test (void) { int xfr_cnt; int to_xfer = 1; int secsize = 4; int boff = 2; xfr_cnt = min(to_xfer, secsize-boff); }
hi, try to avoid any spaces when pass arguments to macro which uses formal parameters. Another way - use additional brackets for complex arguments. Regards, Oleg