2008/02/26

extern "C"

Reference: http://blog.anglee.org/2007/02/extern-c.html

簡單來說

有個 function 定義為 void func(int a, float b);

用 C Compiler compile 後內部名稱會類似 _func
用 C++ Compiler compile 後內部名稱會類似 _func_int_float

C++ compiler 會在 function call 出現在 extern "C" scope 中時,產生並使用 C style 的內部名稱。

要內部名稱一樣 Linking 時才不會出錯。

No comments:

Post a Comment