User Profile

Collapse

Profile Sidebar

Collapse
JohnZ
JohnZ
Last Activity: Aug 13 '08, 12:20 AM
Joined: Aug 12 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • JohnZ
    replied to #define macro with multiple parrams
    in C
    Thank you very much, I understand what I'm doing wrong now....
    See more | Go to post

    Leave a comment:


  • JohnZ
    replied to #define macro with multiple parrams
    in C
    Shouldn't the "..." allow 0 or more arguments? so that the below should accept 3 arguments or more.

    #define LOG(level, device, pcString, ...) \
    if (level < SERIAL_LOG_LEVE L) _log(device, pcString, ## __VA_ARGS__)

    Shouldn't it?

    Thank you....
    See more | Go to post

    Leave a comment:


  • JohnZ
    replied to #define macro with multiple parrams
    in C
    Ok, that works with 1 or more arguments, but if i do

    LOG(1, 0, "hello world");

    compiler says too few argument in macro.

    I'm using IAR by the way.

    Thank you....
    See more | Go to post

    Leave a comment:


  • JohnZ
    started a topic #define macro with multiple parrams
    in C

    #define macro with multiple parrams

    Hi,
    I'm trying to define a macro that calls a log function:

    #define LOG(level, device, pcString, args ...) if (level < SERIAL_LOG_LEVE L) _log(device, pcString, ## args)

    void _log (unsigned char device, const char *pcString, ...);

    I want the macro to accept multiple args with "..." but the compiler didn't like it. It works fine if i simply do.

    #define LOG(level, device,...
    See more | Go to post
No activity results to display
Show More
Working...