Suppose bad_name
is a restricted identifier for example that I do not want to be part of the struct. I am looking for a mechanism to force a compilation failure in that case.
example.h
struct example {
int okay_name;
int bad_name;
}
main.cc
#include "example.h"
int main() {
example ex;
// cause compilation to fail here if bad_name is a member of ex
return 0;
}
There are probably ways to cause a failure at runtime by simulating reflection, but is there a way to do this at compile time?