How to use C api in C++ ?
C++ 可以引用其他 C語言寫的 api,這不意外。
但要怎麼做?
C++:
請在把要使用的 C api 的 header 用 extern “C” 包起來
而要被使用的 C api 的 header:
demo_c_api_A.h:
你也可以不要直接用 extern 標全部,單獨寫:
延伸:extern 是什麼?
ref. Why use #ifndef CLASS_H and #define CLASS_H in .h file but not in .cpp?
Last updated