Keil Logo

Variable args in macros..

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Umar Q.
Posted
17-Nov-2006 07:32 GMT
Toolset
C51
New! 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

Read-Only
Author
Andy Neil
Posted
17-Nov-2006 11:15 GMT
Toolset
C51
New! RE: Variable args in macros..

"Does the C51 support variable arguments in macros"

Does any standard 'C' preprocessor support variable arguments in macros?!

Read-Only
Author
Dan Henry
Posted
17-Nov-2006 15:35 GMT
Toolset
C51
New! RE: Variable args in macros..

"Does any standard 'C' preprocessor support variable arguments in macros?!"

C99 does, but the manual should tell the OP that C51 does not conform to C99.

Read-Only
Author
Drew Davis
Posted
17-Nov-2006 18:41 GMT
Toolset
C51
New! RE: Variable args in macros..

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.)

Read-Only
Author
Jon Ward
Posted
17-Nov-2006 22:04 GMT
Toolset
C51
New! RE: Variable args in macros..

Does Keil have any plans to implement C99 compliance?

Not at the current time. However, if customer demands dictate, we may augment the compiler with features of the C99 Specification.

For more information about the history of C, refer to the following knowledgebase article:

http://www.keil.com/support/docs/1893.htm

Jon

Read-Only
Author
Umar Q.
Posted
18-Nov-2006 21:37 GMT
Toolset
C51
New! RE: Variable args in macros..

Yes indeed C99 compliance would be great. The closer C51 is to prevalent compilers out in the market the better.

Thanks for the info.

Umar

Read-Only
Author
Andy Neil
Posted
19-Nov-2006 00:44 GMT
Toolset
C51
New! Prevalent?

Is C99 yet the "prevalent" version in the market?

Particularly in the 8051-class market?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.