Generate include file name in a macro

前端 未结 3 2120
日久生厌
日久生厌 2020-12-05 23:43

I\'m trying to generate include file name in macro. This is supposed to be legal in C++:

#define INCLUDE_FILE \"module_impl_win.hpp\"
#include INCLUDE_FILE
<         


        
3条回答
  •  半阙折子戏
    2020-12-06 00:46

    I'd do this using a helper quoting macro. Something like this will give you what you want:

    #define QUOTEME(M)       #M
    #define INCLUDE_FILE(M)  QUOTEME(M##_impl_win.hpp)
    
    #include INCLUDE_FILE(module)
    

提交回复
热议问题