Why would you use 'extern “C++”'?

前端 未结 10 1427
失恋的感觉
失恋的感觉 2020-12-12 17:37

In this article the keyword extern can be followed by \"C\" or \"C++\". Why would you use \'extern \"C++\"\'? Is it practical?

10条回答
  •  春和景丽
    2020-12-12 18:25

    The #1 reason I use extern "C" is to avoid C++'s name mangling rules. This is very important if you are working in a .Net language and want to PInvoke into a particular native function. The only way to do this is with name mangling disabled.

提交回复
热议问题