Comments on: Variable length C macros/2009/05/30/variable-length-c-macros/ Commercial gaming for Linux Fri, 09 Nov 2012 18:53:38 +0000 http://wordpress.org/?v=2.8.4 hourly 1 By: Maciej Mrozowski/2009/05/30/variable-length-c-macros/comment-page-1/#comment-1511 Maciej Mrozowski Fri, 15 Jan 2010 18:42:43 +0000 /?p=221#comment-1511 Err, I may be missing something, but following code always worked for me in GCC: #define FORMAT(level,format,args ...) "%-6s [%s] "format, #level, logger->name.c_str(), ##args so: #define macro(args ...) call_function(##args) (I see Torbjörn provided link for it) Err, I may be missing something, but following code always worked for me in GCC:

#define FORMAT(level,format,args …) “%-6s [%s] “format, #level, logger->name.c_str(), ##args

so:

#define macro(args …) call_function(##args)

(I see Torbjörn provided link for it)

]]>
By: Torbjörn Andersson/2009/05/30/variable-length-c-macros/comment-page-1/#comment-372 Torbjörn Andersson Tue, 02 Jun 2009 09:55:23 +0000 /?p=221#comment-372 It should perhaps be pointed out that this form of variadic macros is a GCC extension. Nothing wrong with that, but I think it's good to be aware of it. It's been there for as long as I can remember, and I might even have used it once or twice myself: http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Variadic-Macros.html The CPP manual has some more information, but I haven't had the time to digest it. There does seem to be a couple of ways of dealing with the trailing comma, but unfortunately they too are GCC extensions: http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html It should perhaps be pointed out that this form of variadic macros is a GCC extension. Nothing wrong with that, but I think it’s good to be aware of it. It’s been there for as long as I can remember, and I might even have used it once or twice myself:

http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Variadic-Macros.html

The CPP manual has some more information, but I haven’t had the time to digest it. There does seem to be a couple of ways of dealing with the trailing comma, but unfortunately they too are GCC extensions:

http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

]]>
By: Michael Simms (CEO and head of Development)/2009/05/30/variable-length-c-macros/comment-page-1/#comment-356 Michael Simms (CEO and head of Development) Sat, 30 May 2009 17:14:01 +0000 /?p=221#comment-356 Thanks {:-) (If Id binned it, I wouldnt have been able to say thanks, so, I kept it) Thanks {:-)
(If Id binned it, I wouldnt have been able to say thanks, so, I kept it)

]]>
By: Max/2009/05/30/variable-length-c-macros/comment-page-1/#comment-355 Max Sat, 30 May 2009 11:14:15 +0000 /?p=221#comment-355 Quite good that you find out about these solutions and even better that you release them, might come in handy one day when someone is doing something similar. The main problem in coding is actually to find out about all the capabilities a language has to offer. Actually that seems to be the main problem with many things. Most of the time you just don't know that certain things are allowed. Quite good that you find out about these solutions and even better that you release them, might come in handy one day when someone is doing something similar.
The main problem in coding is actually to find out about all the capabilities a language has to offer.
Actually that seems to be the main problem with many things.
Most of the time you just don’t know that certain things are allowed.

]]>
By: RK/2009/05/30/variable-length-c-macros/comment-page-1/#comment-354 RK Sat, 30 May 2009 10:00:50 +0000 /?p=221#comment-354 Typo: "This means that in gcc, is you wanted to create a define..." "is" should be "if" in this sentence. Feel free to Moderate this comment into oblivion once you've fixed the typo. :) Typo: “This means that in gcc, is you wanted to create a define…”
“is” should be “if” in this sentence.

Feel free to Moderate this comment into oblivion once you’ve fixed the typo. :)

]]>