Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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 "...
John's user avatar
  • 901
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, ...
Anton Kochkov's user avatar
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__), ...
Anton Kochkov's user avatar
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",...
user1692342's user avatar
  • 5,237