title: Why to add "extern" keyword if the global variable is external by default?
body: <p>main.cpp</p>
  <pre><code>#include &lt;iostream&gt;
  
  extern int g_x; // this extern is a forward declaration of a variable named g_x that is defined somewhere else
  
  int main()
  {
      std::cout &lt;&lt; g_x; // prints 2
  
      return 0;
  }
  </code></pre>
  <p>add.cpp</p>
  <pre><code>int g_x { 2 };
  </code></pre>
  <p>If I delete extern in main.cpp, then the code does not work. One the other hand, I don't need extern in add.cpp. Global variables are external by default, but still. Is it because external linkage is a &quot;one-sided relation&quot; between two entities that are linked in different files?</p>