A sample c program is given below:
#include <stdio.h>int i = 10;i = 25;int main(void){ printf("%d\n", i); return 0;}
When it is compiled using gcc
, it throws redefinition error.
warning: data definition has no type or storage classi = 25;^warning: type defaults to ‘int’ in declaration of ‘i’ [-Wimplicit-int]error: redefinition of ‘i’note: previous definition of ‘i’ was hereint i = 10;
I have reassigned a value to that variable i
. Why does the compiler interpret it as a redefinition?