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

前端 未结 5 1752
轮回少年
轮回少年 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:30

    Templates aren't actual code, they're just guidelines to the compiler for how to generate the code once the template parameters are known. As such they don't actually exist until you try to use them. You can't provide linkage to something that doesn't exist.

提交回复
热议问题