I’ve read the various other questions on this but they either dont work or im otherwise stuck.
I’m trying to dynamically #import
a file based on build flags where my imported file name is of the form:
hardware_<hardware>_<version>.h
I can make it work, but only without the .h
file extension, which isnt ideal.
How do I modify this to have .h
on the end?
./hardware_XXX_YYY:
#define FOO "bar"
./main.cpp:
#include <iostream>
#define HARDWARE XXX
#define HARDWARE_VERSION YYY
#define CCC(x) #x
// This fails:
//#define BBB(ha, ver) CCC(hardware_##ha##_##ver##.h)
// This works:
#define BBB(ha, ver) CCC(hardware_##ha##_##ver)
#define AAA(ha, ver) BBB(ha, ver)
#include AAA(HARDWARE, HARDWARE_VERSION)
int main() {
std::cout << FOO << 'n';
}