I have a function call in a program that I'm maintaining has 28 arguments for a printf call. It's printing a lot of data in a CSV file. I have problems following finding where what goes and I have some mismatches in the parameters types. I enabled -Wall in gcc and I get warnings like:
n.c:495: warning: int format, pointer arg (arg 15)
n.c:495: warning: format argument is not a pointer (arg 16)
n.c:495: warning: double format, pointer arg (arg 23)
The function is like this:
fprintf (ConvFilePtr, "\"FORMAT3\"%s%04d%s%04d%s%s%s%d%s%c%s%d%c%s%s%s%s%s%s%s%11.lf%s%11.lf%s%11.lf%s%d\n", some_28_arguments_go_here);
I would like to know if there is a vim plugin that highlights the printf format specifier when i go with the cursor over a variable.
Other solutions? How to better reformat the code to make it more readable?
Not sure I know a good vim trick off the top of my head, but I know a good C macro to make it a little easier:
#define last( f, a, ft, ... ) f ft, a, __VA_ARGS__
#define pair( f, a, ftat ) last( f, a, ftat )
// ...
printf( pair( "%s", "hello",
pair( "%s", "world",
pair( "%c", '\n',
last( "%4x", 0xfeed,
"%f\n", 3.14159 )))));
split the format string and the call into several fprintf calls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With