Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cpp: delay #include's until second pass

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.

like image 482
bukzor Avatar asked Sep 10 '26 21:09

bukzor


1 Answers

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>.

like image 93
cHao Avatar answered Sep 13 '26 05:09

cHao