Why can't templates be within extern “C” blocks?

前端 未结 5 1779
轮回少年
轮回少年 2020-11-30 11:06

This is a follow-up question to an answer to Is it possible to typedef a pointer-to-extern-“C”-function type within a template?

This code fails to compile w

5条回答
  •  余生分开走
    2020-11-30 11:32

    Because template function names need to be decorated with additional information, and extern "C" turns decoration off. The purpose of extern "C" is to be able to declare functions that can be called with C linkage, which is something that will never work with a template function obviously.

提交回复
热议问题