In the following sample code:
#include <stdio.h>
#include "my_macros.h"
int main() {
int one = 1, two = 2;
MY_MACRO_NO_ARGS("This message takes no arguments");
MY_MACRO_1INT("This message takes one integer %d", int, one);
MY_MACRO_1INT("This message also takes one integer %d", int, two);
MY_MACRO_2INT("This message takes two integers: %d and %d", int, one, int, two);
return 0;
}
the macro MY_MACRO takes string, type name, and value that is the same type as preceding argument.
What I would like to do: Have the compiler give a unique ID for each macro call, and dump that into a file with call's arguments. So, the above code would generate something like:
File format: macro-name,unique-id,type1,type2,type3,....
MY_MACRO_NO_ARGS,63534
MY_MACRO_1INT,45632,int
MY_MACRO_1INT,74322,int
MY_MACRO_2INT,75325,int,int
I can change anything in the sources.
How can I do that?