My goal is to be able to create a static variables solely in header with a macro that would take care of initializing it in a .cpp
file for me with value I've provided. It should look something like this:
struct UserDefaults {
STATIC(bool, isFullscreen, true)
STATIC(bool, isBorderless, false)
STATIC(std::string, profileName, "")
}
Which would be equal to:
// .hpp file
struct UserDefaults {
static bool isFullscreen;
static bool isBorderless;
static std::string profileName;
}
// .cpp file
bool UserDefaults::isFullscreen = true;
bool UserDefaults::isBorderless= false;
std::string UserDefaults::profileName = "";
I've looked at How to have static data members in a header-only library?, but I wasn't able to apply Pesche's solution for my case.