Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22040

How to tell the compiler/pre-processor to generate a unique ID for each occurrence of a macro call and dump it to text file? [closed]

$
0
0

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?


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>