title: What is the difference between the global variables in C and C++?
body: <p>I have tested the following code:</p>
  
  <p>in file <strong>a.c/a.cpp</strong></p>
  
  <pre><code>int a;
  </code></pre>
  
  <p>in file <strong>b.c/b.cpp</strong></p>
  
  <pre><code>int a;
  int main() { return 0; }
  </code></pre>
  
  <p>When I compile the source files with <strong>gcc *.c -o test</strong>, it succeeds.</p>
  
  <p>But when I compile the source files with <strong>g++ *.c -o test</strong>, it fails:</p>
  
  <pre><code>ccIJdJPe.o:b.cpp:(.bss+0x0): multiple definition of 'a'
  ccOSsV4n.o:a.cpp:(.bss+0x0): first defined here
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>I'm really confused about this. Is there any difference between the global variables in C and C++?</p>