Code:
/* file1.c */
#include<stdio.h>
int Global_Variable = 12;
void SomeFunction(void);
int main(void)
{
SomeFunction();
printf("%d\n", Global_Variable);
return 0;
}
/* file2.c */
int Global_Variable;
void SomeFunction(void)
{
++Global_Variable;
}
Output: 13
Code:
/* file1.c */
#include<stdio.h>
int Global_Variable;
void SomeFunction(void);
int main(void)
{
SomeFunction();
printf("%d\n", Global_Variable);
return 0;
}
/* file2.c */
int Global_Variable = 24;
void SomeFunction(void)
{
++Global_Variable;
}
Output: 25
Compilers have pretty much always supported that convention though haven't they? It definitely isn't the really worrisome kind of undefined behaviour anyway. Not like dangling pointers, uninitialized variables, bad casts due to CPU alignment and or endianness issues, signed shifts, division by zero errors. This is more like "undefined but implied behaviour".