Why is there no error in this program?

--- ac ----

int i; // external definition

---- main.c ------

int i=0; // external definition 

int main(void)
{
i=0;
}

In both files iis an external defnition in each translation unit and is iused in the expression. This should violate:

If an identifier declared with external connection is used in the expression (except as part of the operand of the sizeof operator whose result is an integer constant), somewhere in the entire program there should be only one external definition for the identifier; otherwise there should be no more than 1,140).

+4
source share
1 answer

This custom behavior is a common extension implemented in many C compilers.

C99 (. . 32-34). , , Relaxed Ref/Def, , UNIX OS C C89. , , . .

, C : Strict Ref/Def Initialization. C .

P.S. , i a.c , . . "" . .

+2

Source: https://habr.com/ru/post/1669646/


All Articles