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

string constant in macro

Hello,

In my C code, I have:
#define message
message("Start\n");

When I look at the SRC file, I see:

RSEG ?CO?MAIN
?SC_0:
DB 'S' ,'t' ,'a' ,'r' ,'t' ,00AH,000H

; message("Start\n");

Why does the C51 version 1.32 keep "Start\n" in the output? Does this also happen to newer version?

Thanks,
Anh

Parents
  • Why does the C51 version 1.32 keep "Start\n" in the output? Does this also happen to newer version?

    It does it because that is what you told the compiler to do.

    The line

    #define message

    defines a null macro for message.

    The line

    message("Start\n");

    expands as

    ("Start\n");

    I can only assume that what you want is:

    #define message(x)
    message("Start\n")
    

    Jon

Reply
  • Why does the C51 version 1.32 keep "Start\n" in the output? Does this also happen to newer version?

    It does it because that is what you told the compiler to do.

    The line

    #define message

    defines a null macro for message.

    The line

    message("Start\n");

    expands as

    ("Start\n");

    I can only assume that what you want is:

    #define message(x)
    message("Start\n")
    

    Jon

Children