What does β€œx” mean in a typical xstr macro?

Common practice is to define string macros like:

#define str(token) #token #define xstr(token) str(token) 

Why is the x prefix used? Does it make sense "x"?

(I suppose that perhaps it means β€œadvanced” (if any), but I have no evidence to support this.)

+7
c c-preprocessor naming-conventions
source share
1 answer

When I use x before the name of the macro or function call, I use it to denote advanced use, and I think I'm not alone.

For your example, use str for the token string, but for extended use, use xstr , that is, to extend the macro argument and its result. For comparison, when only one of the macros should be used most of the time, and the other for internal implementations, I would do the following:

 #define _str(token) #token #define str(token) _str(token) 
0
source share

All Articles