What does mean for a name or type to have a certain language linkage?

前端 未结 7 2109
南笙
南笙 2021-02-01 02:14

According to (c) ANSI ISO/IEC 14882:2003, page 127:

Linkage specifications nest. When linkage specifications nest, the innermost one determines the langu

7条回答
  •  有刺的猬
    2021-02-01 02:40

    extern "C" typedef void FUNC();
    FUNC f2;
    // the name f2 has C++ language linkage and the
    // function's type has C language linkage
    

    The name FUNC is declared with "C" linkage because it says extern "C" on the first line.

    The name f2 has C++ linkage because that is the default, and no other linkage is given on line two.

    The fact that the name f2 is used to refer to a function with C linkage doesn't change the linkage of the name.

提交回复
热议问题