This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiler Crashed on Specific Macro

Hi all,
I defined a macro as

#define min(a,b)       (((a) < (b)) ? (a) : (b))
and used it as
xfr_cnt = min(to_xfer, secsize - boff);
but every time compiler crashed on this C file. It is ok after I expanded it as
xfr_cnt= ((to_xfer < (secsize - boff)) ? (to_xfer) : (secsize - boff));
Strange huh? Please help!

Parents
  • 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);
    }
    

Reply
  • 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);
    }
    

Children
No data