There are some C projects with structs full of ifdefs (for ex. WolfSSL https://github.com/wolfSSL/wolfssl/blob/bb70fee1ecff8945af8179f48e90d78ea7007c66/wolfssl/internal.h#L2792)
struct {
int filed_1;
int field_2;
#ifdef SETTING_A
int filed_b;
#endif
#ifdef SETTING_B
int field_b;
#endif
}
The reason is to reduce struct size for unused options. There are a lot of ifdefs! Everywhere!
Is there a C++ way to get rid of those ifdefs, retaining the ability for compiler to optimize out unused fields? Maybe with templates, usings or CRTP inheritance?