Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22248

Why does the compiler interpret assignment as definition

$
0
0

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?


Viewing all articles
Browse latest Browse all 22248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>