According to the One Definition Rule, there can be two definitions of the same class if a list of constraints are respected.
Let's consider this header file:
#ifdef VAR
typedef int int_t;
#else
typedef int* int_t;
#endif
class C {
public:
int_t i;
};
All the source files that will include this header file will define the class C. The definition of this class will consist of the same sequence of tokens in every translation units. However, the underlying type of the member i is not the same depending on how the type int_t has been declared.
If I take the list of the constraints from cppreference.com, it seems that this code is respecting the One Definition Rule. But, I does not make sense to me because the C object in a program may represent different data.
Is this code breaking the One Definition Rule? If yes, which part of the ODR? If no, is this code problematic in some way?