Understanding of extern "C"
2012-01-01 18:08
190 查看
In this example, there are two files, namely f1.c and test.cc.
f1.c
test.cc
Compiler will compile the source code according to the format of the files. Provided that extern "C" is not used, function f1 in f1.c will be a short name compared to a long name in test.cc in assemble language due to overload in C++. With extern "C", developers
can use C in C++.
We can make C style compile in .cpp or .cc files by extern "C".
f2.cc
test.cc
f1.c
void f1() { return; }
test.cc
extern "C" { extern void f1(); } int main() { f1(); return 0; }
Compiler will compile the source code according to the format of the files. Provided that extern "C" is not used, function f1 in f1.c will be a short name compared to a long name in test.cc in assemble language due to overload in C++. With extern "C", developers
can use C in C++.
We can make C style compile in .cpp or .cc files by extern "C".
f2.cc
extern "C" { void f2() { return; } }
test.cc
extern "C" { extern void f2(); } int main() { f2(); return 0; }
相关文章推荐
- the meaning of extern "C"
- some special cases of "extern" in C
- extern "C" {}
- #ifdef __cplusplus extern "C" { #endif 的解释
- C与C++的兼容问题——extern "C"的用法解析
- extern "C" 与 __stdcall使用
- extern "C"的用法解析
- 错误Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
- extern "C" 引起的 error C2059
- 在C++程序中调用被C编译器编译后的函数,为什么要加extern "C"?
- Understanding the implications of IQueryable<T>
- #ifdef __cplusplus extern "C" { #endif 的解释
- 问题解决:javax.servlet.jsp.el.ELException: The "." operator was supplied with an index value of type "java.lang.String" to be applie
- C++项目中的extern "C" {}
- c++中的 extern "C"
- Demo of Python "Map Reduce Filter"
- extern "C"的用法解析
- extern "C"
- Data source rejected establishment of connection, message from server: "Too many connections"
- extern "c" 动态链接库符号表导出问题 以及函数参数压栈顺序