variadic macros

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

variadic macros

Robert M. Münch
Hi, why does this give an error:

// define variadic macro using __VAR_ARGS__
#ifdef DEBUG
#define LOG(format, ...) odprintf(format, __VAR_ARGS__)
#else
#define LOG(format...)
#endif

abc.h:5:43: error: '__VAR_ARGS__' undeclared (first use in this function)
 #define LOG(format, ...) odprintf(format, __VAR_ARGS__)


IIRC C99 allows using variadic macro parameters. Is there anything special to consider?

--  
Robert M. Münch  
M: +41 79 65 11 49 6  

Saphirion AG  
An der Lorze 9  
CH - 6300 Zug  
T: +41 41 55 20 21 1  
F: +41 41 55 20 21 2  

http://www.saphirion.com 
smarter | better | faster  



------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: variadic macros

Paul Moore
On 29 September 2014 14:40, Robert M. Münch <[hidden email]> wrote:
> IIRC C99 allows using variadic macro parameters. Is there anything special to consider?

What version of gcc are you using, and does it claim to support this
C99 feature? Do you need to add -std=c99?
Paul

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: variadic macros

Robert M. Münch
-----Original Message-----
Absender: Paul Moore <[hidden email]>
Antworten: MinGW Users List <[hidden email]>>
Datum: 29-Sep.-2014 at 17:35:36
Empfänger: MinGW Users List <[hidden email]>>
Betreff:  Re: [Mingw-users] variadic macros

> What version of gcc are you using, and does it claim to support this
> C99 feature? Do you need to add -std=c99?

I’m already using -std=c99 and it’s GCC 4.8.1

I think I got this code compiled with a 4.7.x version already. That’s why I wonder why it’s now not compiling anymore.

--  
Robert M. Münch  

http://www.saphirion.com 
smarter | better | faster  



------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: variadic macros

Andy Moreton
In reply to this post by Robert M. Münch
On Mon 29 Sep 2014, Robert M. Münch wrote:

> Hi, why does this give an error:
>
> // define variadic macro using __VAR_ARGS__
> #ifdef DEBUG
> #define LOG(format, ...) odprintf(format, __VAR_ARGS__)
> #else
> #define LOG(format...)
> #endif
>
> abc.h:5:43: error: '__VAR_ARGS__' undeclared (first use in this function)
>  #define LOG(format, ...) odprintf(format, __VAR_ARGS__)
>
>
> IIRC C99 allows using variadic macro parameters. Is there anything special to consider?

C99 does allow variadic macros, but it uses __VA_ARGS__

HTH,

    AndyM


------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: variadic macros

Robert M. Münch
-----Original Message-----
Absender: Andy Moreton <[hidden email]>
Antworten: MinGW Users List <[hidden email]>>
Datum: 30-Sep.-2014 at 00:01:19
Empfänger: [hidden email] <[hidden email]>>
Betreff:  Re: [Mingw-users] variadic macros

> C99 does allow variadic macros, but it uses __VA_ARGS__

And I just got new glasses… Thanks.

--  
Robert M. Münch  

http://www.saphirion.com 
smarter | better | faster  



------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe