0.c
typedef enum nums{
i = 1, j=2
} nums;
// int k = 5; <-- commented out
int main(){
return i;
}
1.c
typedef enum nums{
i = 1, j=2
} nums;
// int k = 5; <-- commented out
If I compile the above with gcc 0.c 1.c I don't get a link error, however, if I uncomment k I will get an error.
2 questions:
1 - How come enums are immune from link issues, aren't i and j just another int?
2- What happens if enums with same name have different values in different translation units? undefined behaviour?