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

Variable args in macros..

Hi,

I get errors compiling these macros:

#define MYMACRO(name, service_name, ...)                                \ 
  static struct service_name name##_interface = __VA_ARGS__ ;           \ 
  struct service name = { NULL, NULL, service_name##_name, & name##_interface }
#endif

The errors are:
C301: identifier expected
C301: identifier expected
C304: bad macro parameter list

Does the C51 support variable arguments in macros? If not, any work arounds?

Regards,
Umar

Parents
  • GCC has had variadic macros for a while. In fact, that compiler has lots of extensions to C and C++, which sometimes trips people up when they switch to a standard compiler.

    Some of the GCC extensions got adopted in C99, including var args for macros and variable length arrays.

    Does Keil have any plans to implement C99 compliance? (It's only been seven years... if we're not careful they'll issue C09 before the work can be finished.)

Reply
  • GCC has had variadic macros for a while. In fact, that compiler has lots of extensions to C and C++, which sometimes trips people up when they switch to a standard compiler.

    Some of the GCC extensions got adopted in C99, including var args for macros and variable length arrays.

    Does Keil have any plans to implement C99 compliance? (It's only been seven years... if we're not careful they'll issue C09 before the work can be finished.)

Children