title: How does C's "extern" work?
body: <p>I have a C/C++ program that's a plugin to Firefox. Because it's a plugin, it has non-main entry points. Those entrypoints need to be compiled in C because otherwise they get name mangled.However, other functions are over-loaded, so they need to be C++. The solution is extern "C". That much I've already figured out.</p>
  
  <p>However, if I extern "C" around the .c file, I get link errors because the C++ files got name mangled, but the calls in the .c file didn't. At least I <em>THINK</em> that's what's happening.</p>
  
  <p>The solution APPEARS to be to put the extern "C" around the .h file. This SEEMS to mean that the names of the functions declared in the .h file aren't mangled, even when they're defined in the (presumably mangled) .c file. </p>
  
  <p>However, it doesn't really make any sense to me why this would work. Is this a kludge? Am I setting myself up for a hard to find bug later? or is this the right way to solve this?</p>