|
I've run into a little theoretical problem. In a piece of code I'm maintaining there's a set of macros like
#define MAX_OF_2(a, b) (a) > (b) ? (a) : (b) #define MAX_OF_3(a, b, c) MAX_OF_2(MAX_OF_2(a, b), c) #define MAX_OF_4(a, b, c, d) MAX_OF_2(MAX...
Answer Snippets (Read the full thread at stackoverflow):
It is, however, a variadic MAX_OF_N macro:
#include <iostream> #include not sure ....
The only code that I've seen do something like this was not variadic, but used works for one type.
It to recursively define macros.
|
|
Hi,
I was wondering if it is possible to iterate over arguments passed to a variadic macro in C99 or using any GCC extensions ?
For e.g. is it possible to write a generic macro that takes a structure and its fields passed as arguments and prints offset...
Started by vshenoy on
, 6 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
#include <stddef.h> // offsetof....
Struct, a, c); return 0; }
If your structure is described with X-Macros , then it is possible to write a function, or a macro to iterate over all the fields of the structure and print their offset.
|
|
On Sat, 17 Dec 2011 12:45:26 -0800 (PST), lcaminiti <lorcaminiti@gmail.com
Hello all,
Why does Boost.Preprocessor redefines BOOST_PP_VARIAIDCS instead of just
using BOOST_NO_VARIADIC_MACROS from Boost.Config?
Furthermore, GCC supports variadics...
Started by lcaminiti on
, 7 posts
by 4 people.
Answer Snippets (Read the full thread at omgili):
BOOST_PP_VARIADICS macro, I could do:
#include <config.hpp#ifndef BOOST_NO_VARIADIC_MACROS
#define BOOST_PP_NO_VARIADICS_VARIADICS....
Requires more than just superficial variadic macro support.
|
Ask your Facebook Friends
|
In C, is it possible to forward the invocation of a variadic function? As in,
int my_printf(char *fmt, ...) { fprintf(stderr, "Calling printf with fmt %s", fmt); return SOMEHOW_INVOKE_LIBC_PRINTF; }
Forwarding the invocation in the manner above obviously...
Started by Patrick on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
There isn't a way to directly call a variadic function in the standard library)....
And it always relied on esoteric implementation-specific macros, with the vital va_copy() macro only the vprintf version rather than plain printf .
|
|
Hi there.
I was wondering if there was any way to pass parameters dynamically to variadic functions. i.e. If I have a function
int some_function (int a, int b, ...){/*blah*/}
and I am accepting a bunch of values from the user, I want some way of passing...
Started by tommobh on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
To a va_list (using macros from stdarg.h ) and calls its va_listIt might be interesting to try just passing an array, and then use the vararg macros anyway;pos[3] = 4; args->pos[4] = 5;....
The variadic version just converts ...
|
|
I have approximately 30 variadic functions. Each one accepts a path as the final argument, i.e.:
bool do_foo(struct *f, int q, const char *fmt, ...)
In each function, I have to check that the expanded format is less then or equal to a certain size. So...
Started by Tim Post on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In general, if you're writing variadic functions (....
See the comp.lang.c FAQ.
Use variadic macros - like this:
#define FOO(...) do { do_some_checks; myfun(__VA_ARGS__); } while (0)
NB! Variadic macros are C99-only
.
|
|
On Sat, 20 Nov 2010 14:07:25 -0500, Edward Diener <eldiener@tropicsoft.com
Why is there two mutually exclusive macros indicating variadic template
support for gcc ?
There is the established BOOST_NO_VARIADIC_TEMPLATES which says that any
compiler...
Started by Edward Diener on
, 13 posts
by 4 people.
Answer Snippets (Read the full thread at omgili):
In fact an
empty compiler config file_ macros neither
BOOST_HAS_VARIADIC_TMPL nor BOOST_HAS_RVALUE_REFS will be defined
therefore causing in which case variadic....
To promote use of variadic templates depending on that macro.
|
|
On Wed, 24 Nov 2010 09:22:30 +0100, Mathias Gaunard <mathias.gaunard@ens-lyon.org
Variadic macros would allow to support tuples better in Boost.PP, as it
would not be necessary to specify the size of the tuple, and it could be
possible to provide...
Started by Mathias Gaunard on
, 11 posts
by 4 people.
Answer Snippets (Read the full thread at omgili):
The macro takes a "variadic" sequence
and yields:17:45 -0500,....
Library to the sandbox which can use variadic macros and uses my
variadic_macro_data library parentheses, it
wraps them all in extra parentheses.
|
|
On Fri, 06 Aug 2010 01:35:44 -0400, Edward Diener <eldiener@tropicsoft.com
If there is none, then obviously Boost code can not currently use
variadic macros for anything.
Welcome to the world of "Unfortunately it does not meet the triage bar...
Started by Edward Diener on
, 11 posts
by 4 people.
Answer Snippets (Read the full thread at omgili):
Still I would like to see a Boost config macro which ....
Eldiener@tropicsoft.com
If Boost had a configuration macro indicating which compilers support
variadic macros compilers will support
variadic macros.
|
|
On Tue, 24 Nov 2009 16:30:17 +0100, Noob <root@127.0.0.1
Hello,
I've been reading about variadic macros, and have a few questions.
http://en.wikipedia.org/wiki/Variadic_macro
I don't find the term "variadic" in ISO/IEC 9899:TC3. Did the standard...
Started by Noob on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at omgili):
The old trick....
Adding yet function.
In the list of changes they are described as
"macros with a variable number of arguments".
Root@127.0.0.1
Other may be able to say but there is no obvious need to name these
as special macros.
|