Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert sizeof() value to string in preprocessing time

I have to combine C code with some inline assembly.

I allready have simple mechanism converting my enum values and macros into strings:

#define STR(x) #x
#define DEF2STR(x) STR(x)

"string1 " DEF2STR(MACRO_VALUE_2) " string2"

output string after preprocessing is: "string1 2 string2"

Question is, how can I append sizeof(type) value into string? Thanks.

like image 814
Mihalko Avatar asked Oct 20 '25 15:10

Mihalko


1 Answers

You can't - sizeof(type) will be evaluated after macro substitutions have taken place... later in the compilation phases.

Why are you trying to do that? Maybe there's another way to get what you really want done....

like image 111
Tony Delroy Avatar answered Oct 22 '25 04:10

Tony Delroy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!