4 ms·
He mismatched C "static" with Java "static". In C, variables defined in the file scope with static keyword, i.e. defined outside functions will be visible only
by lisivka 10y ago
He mismatched C "static" with Java "static".
In C, variables defined in the file scope with static keyword, i.e. defined outside functions will be visible only within that file. Any attempt to access them from other files will result in unresolved symbol at link time.
I made exact same error when tried to write C code after years of coding in Java. I knew C, but my knowledge was blurry. Despite that, I finished project in time with excellent recommendations. I am senior after all.
- mavelikara 10y agoYou are right - the 'static' itself is a mistake, but not a terrible one. But when the line: Foo foo = new Foo(); is followed up with: assertEquals( if one types in anything other than -1, 0, Integer.MAX_VALUE, Integer.MIN_VALUE etc, big blaring warning alarms should go off in a senior developer's head. Even after it is typed in, when you read through the code it should have stood out to you.