09-10-2014 05:12 AM
Hello,
anyone knows how it's possible to declare functions with a varying number of arguments in CVI 7.1? (later CVI versions can use C99 extension macro)
example: Func(int i, ... );
Thanks
09-10-2014 05:53 AM
This is definitely possible by means of va_list and va_start macros: I have been using it since at least CVI5.
09-10-2014 06:04 AM
And what about macros?
example: #define MACRO(param1, ...)
09-10-2014 07:36 AM
What do you mean with "macros"? va_start and va_arg already are macros, defined in stdarg.h
09-11-2014 04:00 AM
I meant a self defined macro with variable arguments - here '...' doesn't work - you will get a compiler error because this is a C99 extension - you have to use __VA_ARGS__
example: #define MACRO(param1, __VA_ARGS__)
09-15-2014 12:48 PM
Variable-length macros are supported only in CVI 9.0 and later.
Luis
09-16-2014 01:11 AM
That's not right, you can use "__VA_ARGS__" instead of "..." for defining variable macro length...
09-17-2014 11:32 AM
I'm not exactly sure what you mean. This is how you're supposed to use variable argument macros:
#define debug_printf(format, ...) fprintf (stderr, format, __VA_ARGS__);
debug_printf ("%s %s %s", "a", "b", "c");
You can do this in CVI 9.0 and later. You cannot do it in CVI 7.1.
You say that you can replace "..." with "__VA_ARGS__"? How, exactly? Like this?
#define debug_printf(format, __VA_ARGS__) fprintf (stderr, format, __VA_ARGS__);
debug_printf ("%s %s %s", "a", "b", "c");
That doesn't work in any version of CVI, so far as I know.