can static declared global variable can be accessed with extern in another file?

c, global, static

Solution

No! `static` limits the scope of the variable to same translation unit. `static` gives the variable an Internal Linkage and this variable cannot be accessed beyond the translation unit in which was created.

If you need to access a variable accross different files just drop the `static` keyword.

Problem

I have one doubt if i declared global variable with static. file1.c ``` static int a=5; main() { func(); } ``` can it be access in another file2.c using extern ? file2.c ``` func() { extern int a; printf(a); } ``` or only global variable declared without static can be access using extern?

Original source

Related problems