All Questions
4 questions
2
votes
1
answer
590
views
Macro for printing variadic arguments, with the option of no arguments
I want to implement the following macro:
ASSERT(condition, ...)
Which is defined like this:
1. If it gets only one parameter - if the condition is false we just print "...
1
vote
2
answers
1k
views
Converting the list of numbers in hexadecimal string in C preprocessor
How to convert the list of the 16bit numbers to the hexadecimal string like "\x0f\x56\x44\xe0".
How do these 16 bit values look? They are the result of the macro expansion too #define make_word(arg1, ...
4
votes
2
answers
3k
views
How to expand macro and delete comma
For example I want to write my own printf() alternative, but I have to perform calculations on the variable arguments:
#define log(fmt_string, ...) my_log(fmt_string, pack_args(__VA_ARGS__), ...
0
votes
2
answers
3k
views
How to use Variadic macros with fprintf
I am trying to print logs into a file by writing macros.
My macro looks like as shown below:
#define LOG(fmt,...){\
FILE *F;\
F = fopen("output.txt","a");\
fprintf(F,fmt " %s %d",...