Has anyone used variadic functions in their FRC code? I want to have a variadic debugging function, but the function appears to get ignored when called. I know the stdarg.h is available and the code compiles, bug I get zero output from the function call (it should do a varying number of printf’s, including some for general newlines, which it does not do).
If you need to see code, I can probably get a small example of what I want posted.
First, add ‘#include <stdarg.h>’ (without quotes at the top of the user_routines.c file).
void Debug_uchar(unsigned char count,...)
va_list ap; /* the list of variables - needed for variadic functions */
unsigned char i; /* counter variable - for loop will iterate through the arguements */
if (num_of_prog_loops == DEBUG_LOOPS)
va_start(ap, count); /* we need to initialize the arguement list */
for (i = 0; i < count; i++)
", i, va_arg(ap, unsigned char);
/* num_of_prog_loops is reset at the bottom of ????? routine */
num_of_prog_loops is a global variable being incremented, then set to 0 after a certain number of loops
Your printfs will compile but will fail to work if you don’t #include <stdio.h>.
This is in the user_routines.c file, which does have that defined. I’d expect the printf calls to work, since I’ve used them outside the function in the same source file. It seems that the program doesn’t even go into the variadic function.