This is hardly what I'd call "great style" but a technique I use in a pinch, especially in restricted systems, called XMacro
Basically, make a file with an extension like .xmacro
(I will use MyXMacro.xmacro
) then fill it with data like this:
XMACRO_INT(i)
XMACRO_INT(j)
XMACRO_STRING(s)
XMACRO_STRING(t)
#undef XMACRO_INT
#undef XMACRO_STRING
Then in your code you write something like this:
#define XMACRO_INT(x) int x ;
#define XMACRO_STRING(x) std::string x ;
#include "MyXMacro.xmacro"
void print() {
# define XMACRO_INT(x) std::cout << x ;
# define XMACRO_STRING(x) std::cout << x ;
# include "MyXMacro.xmacro"
}
At a certain point though, writing a script and incorporating it into your build is a better choice.