static vs extern “C”/“C++”

前端 未结 5 1696
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 03:23

What is the difference between a static member function and an extern \"C\" linkage function ? For instance, when using \"makecontext\" in C++, I need to pass a pointer to f

5条回答
  •  忘掉有多难
    2020-11-29 03:59

    Note, that extern C is the recommended way of C/C++ interoperability. Here is the master talking about it. To add to eduffy's answer: note that static functions and variables in the global namespace are deprecated. Use an anonymous namespace at least.

    Back to extern C: if you don't use extern C you will have to know the exact mangled name and use it. That is much more of a pain.

提交回复
热议问题