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

Why can't GCC's typeof() be stringified?

$
0
0

I'd like to print the type that typeof() outputs, but typeid is only available in C++. Why can't I use stringification to get the name of this type?

#define GET_STRING(s) #s#define example(input)                              \    do {                                            \        char test[20] = GET_STRING(typeof(input));  \        printf(test);                               \    }                                               \    while (0)                                       \

This would print out "typeof()" with input stringified inside. Why does the preproccessor stringify before typeof() is handled? Is there a way to override this behavior?

You can stringify types directly if they are passed like GET_STRING(int), so using typeof() should have the same behavior.


Viewing all articles
Browse latest Browse all 22137

Trending Articles



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