I want to include component.h.gen
from component.h
.
I've already seen that I can use __FILE__
with #include
and that results in recursive inclusion if there is no header guard.
Is there a way to append a C string literal and include the result? This is what I've tried so far:
#define CAT_IMPL(s1, s2) s1##s2
#define CAT(s1, s2) CAT_IMPL(s1, s2)
#define DO_IT CAT(__FILE__, ".gen")
#include DO_IT
But this results in the same recursion with the file including itself - the ".gen"
part is not used - and I get this warning with MSVC:
warning C4067: unexpected tokens following preprocessor directive - expected a newline
Is there a solution that would work with gcc/clang/msvc?
Note that I'm planning on using this in hundreds if not thousands of files and I would like to simplify my life by just copy-pasting the same code - that's why I'm trying to get this to work.