Is there any potential problem that I should be aware of if appending more enumeration in an the header of a shared library which is provided by others? The code of the said library could not be modified and recompiled through I can see them :(.
I think the enum value would be replaced by a char
or an int
and etc when the code is compiling. If the appended value does not overflow the underlying type, I think it should not influence the functions of the said library. If I am wrong, please let me know.
Say there is enumeration named as named SeatPosition, say the original enumeration is something like this:
typedef enum POSITON_INFO{
FIRST_ROW_LEFT,
FIRST_ROW_RIGHT,
SECOND_ROW_LEFT,
SECOND_ROW_RIGHT,
}POSITON_INFO;
Now, I want to append more values to extern the function that the library offord.Just like this:
typedef enum POSITON_INFO{
FIRST_ROW_LEFT,
FIRST_ROW_RIGHT,
SECOND_ROW_LEFT,
SECOND_ROW_RIGHT,
THIRD_ROW_LEFT,
THIRD_ROW_RIGHT,
}POSITON_INFO;
As molbdnilo notes in the comments: No, this is not possible. It violates the One Definition Rule. It is also likely to cause additional problems, e.g. with switch statements in the compiled code. And while this example has only a few enumerators, pushing the number over 255 can affect the underlying type.