Based on the user-defined numeric macro PROBNO
, I want to include a file "prob[PROBNO].hpp"
, and run the function of the same name, prob[PROBNO]()
. The problem here is that I need the quotes around the included file, as < > gives me a file not found error. I'm currently doing the following:
#define STRINGIFY2(x)#x
#define STRINGIFY(x)STRINGIFY2(x)
#define CONCAT2(x,y)x##y
#define CONCAT(x,y)CONCAT2(x,y)
#define PROBNAME CONCAT(prob,PROBNO)
#include STRINGIFY(PROBNAME.hpp)
#include<iostream>
int main(){
std::cout<<PROBNAME()<<'\n';
}
This does the job, but it looks messy. is there any way I can get rid of some of the directives somehow?