writing c++ code in extern c

后端 未结 1 1970
长发绾君心
长发绾君心 2021-01-19 21:37

I\'m trying to implement an external c++ header interface that will be produced as a shared library. Their example interface has c style functionality wrapped in extern \"C\

1条回答
  •  心在旅途
    2021-01-19 22:11

    extern "C" doesn't keep you from using C++ inside the function. It only affects the way that the function is called (including the name of the function). Since the name is not mangled, and the calling sequence might be different from standard C++ calling sequence, you have to make sure that the function is declared as extern "C" in any C++ translation unit in which it appears. Also, "C" names are not namespaced, but you probably knew that.

    And as far as I know, Qt is not doing anything to make your code more or less C-friendly.

    0 讨论(0)
提交回复
热议问题