Variadic Macros
-
I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]:
#define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); }
The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.ARSALAN MALIK
-
I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]:
#define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); }
The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.ARSALAN MALIK
#define CHECK1(x, args) if (!(x)) { printf(args); }
BTW, i have a question. why do you want to do such a thing ? to print only in debug ? if so, you could do a better design, like this :
#if defined(DEBUG) ||defined(_DEBUG)
#define DBG_PRINT printf
#else
#define int DBG_PRINT(const char*, ...) { return 0; }
#endifthis way, you can place some
DBG_PRINT("whatever");
in you code ; it will be executed only in debug mode compilation. -- modified at 5:38 Tuesday 25th July, 2006 -
#define CHECK1(x, args) if (!(x)) { printf(args); }
BTW, i have a question. why do you want to do such a thing ? to print only in debug ? if so, you could do a better design, like this :
#if defined(DEBUG) ||defined(_DEBUG)
#define DBG_PRINT printf
#else
#define int DBG_PRINT(const char*, ...) { return 0; }
#endifthis way, you can place some
DBG_PRINT("whatever");
in you code ; it will be executed only in debug mode compilation. -- modified at 5:38 Tuesday 25th July, 2006#define CHECK1(x, args) if (!(x)) { printf(args); }
How do I pass multiple arguments, e.g. I want printf("%i %i", a, b); :doh:
#if defined(DEBUG) ||defined(_DEBUG)
#define DBG_PRINT printf
#else
#define int DBG_PRINT(const char*, ...) { return 0; }
#endifThis does not compile under VC6:->
ARSALAN MALIK
-
I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]:
#define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); }
The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.ARSALAN MALIK
VC 6 doesn't support that feature, sorry.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
#define CHECK1(x, args) if (!(x)) { printf(args); }
How do I pass multiple arguments, e.g. I want printf("%i %i", a, b); :doh:
#if defined(DEBUG) ||defined(_DEBUG)
#define DBG_PRINT printf
#else
#define int DBG_PRINT(const char*, ...) { return 0; }
#endifThis does not compile under VC6:->
ARSALAN MALIK
Arsalan Malik wrote:
This does not compile under VC6
yes i made a mistake. remove the #define leading on the #else case...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
VC 6 doesn't support that feature, sorry.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ