Fix building with newer versions of Clang.

Clang has started caring that templates have C++ linkage. This just
rearranges where the extern C is specified so that the C++ decls are all
outside of the extern C block.

Issue: PLCR-546