cpp: delay #include's until second pass

早过忘川 提交于 2019-12-13 14:04:06

问题


I'm running my source file through the C preprocessor twice before compiling it, and I want to delay The #include directives until the second pass.

Intuitively, I tried this, but it doesn't work:

##include <zlib.h>

I just need a construct, that when preprocessed, will give #include mylib.


回答1:


You could define a macro, like

#define INCLUDE #include

and then when you include stuff, use the macro instead.

INCLUDE <zlib.h>

In GCC's preprocessor, at least, that gives me #include <zlib.h>.



来源:https://stackoverflow.com/questions/6379404/cpp-delay-includes-until-second-pass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!