How to generate random variable names in C++ using macros?

前端 未结 8 2027
别跟我提以往
别跟我提以往 2020-12-01 07:56

I\'m creating a macro in C++ that declares a variable and assigns some value to it. Depending on how the macro is used, the second occurrence of the macro can override the v

8条回答
  •  伪装坚强ぢ
    2020-12-01 08:57

    Instead of having the preprocesser create a name, you could possibly let the macro user give you a name.

    #define MY_MACRO(varname) int varname = getCurrentTime();
    

提交回复
热议问题