News for hackers. Stuff that matters.
Re:Some Obscure C Features by eMSF on Thursday August 22, 2019 @05:29PM (#20772550)
That's hardly obscure: it's Javascript that's the odd one out of the languages with C-like syntax, with its wacky function-level scoping instead of variable shadowing when using 'var', and falling back to global scope when not declaring a variable properly. Also, C and C++ behave identically with your given example.

A perhaps obscure feature is that you can "unshadow" a global variable like this:

  #include <stdio.h>
  int global = 0;
  int main()
  {
    int global = 1;
    {
      extern int global;
      printf("%d\n", global); // prints 0
    }
  }

There are no comments on this comment yet.