3 ms·
And if b-file.c says "static int foo = 43;" what is the desired behavior?
by fwip 8y ago
And if b-file.c says "static int foo = 43;" what is the desired behavior?
- ghthor 8y agoI'd imagine a compiler error that static values, aka globals, must not differ at compile time. This would likely apply to consts as well.
- c-smile 8y ago"must not differ at compile time" not so, static declaration are local for the compilation unit so you may have as many different foo's as files you have in your project.
- c-smile 8y agoIn C/C++ static declarations are local to the compilation unit. So you will have two separate storages for foo - these will be two independent variables. That's how C and C++ work. And if you will have this (no static): int foo = 45; then linker will complain - "multiple 'foo' entities" as non-static entities have global visibility.