How to stringify an expression in C

前端 未结 7 1339
刺人心
刺人心 2020-12-07 01:53

Is there a way to evaluate an expression before stringification in c?

example:

#define stringify(x)  #x
...
const char * thestring = stringify( 10 *          


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 02:27

    You could write a script (perl?) to use as preprocessor which recognizes the strings to evaluate, evaluates them and then it calls the true cpp on the "evaluated" file.

    Maybe it could work.

提交回复
热议问题