Generate include file name in a macro

前端 未结 3 2112
日久生厌
日久生厌 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:41

    The problem is that eventually your code would look like this:

    #include "module""_impl_win.hpp"
    

    This generates the same warning and error you are seeing but in a slightly more obvious way.

    While the compiler will accept that syntax, the preprocessor will not.

    I don't have a suggestion to make what you are trying to do work. Personally wouldn't want to use that type of macro since it makes it more difficult to navigate the code visually and it would likely inhibit many editors from quickly navigating the code.

提交回复
热议问题