Two developers are writing two units currently. The one unit contains an enumeration definition (which is additionally dependent on compiler switches) , the other one uses the array definition to initialize an array. Currently everything is in sync. How can we avoid to get into trouble if the definition of the enumeration is changed over time, but the array is not. Any ideas for compile time or runtime checks?
abc.h
typedef enum {
A,
#ifdef UseB
B,
#endif
C,
MAX
}My Enum
xyz.c
#include abc.h
int myArray[MAX] = {
1, // A
#ifdef UseB
2, // B
#endif
3
};
Is there a way to get a notification if a new element D is added after C or if the order changes (e.g. A and C are interchanged)?