title: Extern declaration on an extern "C" global variable
body: <p>In C and C++ if I want to use a global variable in other compilation units I will define the variable like:</p>
  
  <pre><code>int g_myVal = 0;
  </code></pre>
  
  <p>This allocates storage for the <code>int</code>.</p>
  
  <p>In the header file I then declare the variable:</p>
  
  <pre><code>extern int g_myVal;
  </code></pre>
  
  <p>This informs the compiler that said symbol exists in some other compilation unit. It is then up to the linker to resolve the symbol.</p>
  
  <p>However if I want the variable to be available with "C" linkage I must define the variable (allocate storage) like:</p>
  
  <pre><code>extern "C" int g_myVal = 0;
  </code></pre>
  
  <p>So how does one then differentiate between allocating storage and just informing the compiler that said symbol exists in another compilation unit?</p>