对于extern "C"的说明
来源:互联网 发布:淘宝市场调研调查报告 编辑:程序博客网 时间:2024/05/23 11:46
Mixed-Language Programming with C++
C++ uses the same calling convention and parameter-passing techniques as C, but naming conventions are different because of C++ decoration of external symbols. By causing C++ to drop name decoration, the extern "C" syntax makes it possible for a C++ module to share data and routines with other languages.
The following example declares prn as an external function using the C naming convention. This declaration appears in C++ source code.
extern "C"
{
void prn();
}
To call functions written in Fortran (or MASM), declare the function as you would in C and use a "C" linkage specification. For example, to call the Fortran function FACT from C++, declare it as follows:
extern "C" { int __stdcall FACT( int n ); }
The extern "C" syntax can be used to adjust a call from C++ to other languages, or to change the naming convention of C++ routines called from other languages. However, extern "C" can be used only from within C++. If the C++ code does not use extern "C" and cannot be changed, you can call C++ routines only by determining the name decoration and generating it from the other language. You can always determine the decoration by using the DUMPBIN utility. Use this approach only as a last resort, because the decoration scheme is not guaranteed to remain the same between versions.
Use of extern "C" has some restrictions:
You cannot declare a member function with extern "C".
You can specify extern "C" for only one instance of an overloaded function; all other instances of an overloaded function have C++ linkage.
For more information on the extern "C" linkage specification, seeLinkage Specifications in C++ Language Reference.
- 对于extern "C"的说明
- ifdef _cplusplus extern "c"的说明
- 关于C中extern的说明
- extern "C"说明
- 对于C语言头文件里面extern的理解
- IOS开发- C语言static和extern对于函数,变量的影响
- static和extern的说明
- extern "C"的用法
- “extern c”的使用
- extern "C" 的用意
- extern "C" 的用意
- "extern" C的用法
- extern “C”的使用
- extern "C" 的作用
- extern C的使用方法
- extern "C"的使用
- extern "C"的使用
- extern “C”的作用
- 猴年马月谈GBDP2004高速编程技术体系
- 一个知名出版商的挫折——解读 Wrox 的历史、现在与未来(转载)
- 今天注册开通
- 一些经典但惊人的知识[ZT]
- 问答:在注册表里增加了一项键值,怎么一重新启动就没了?
- 对于extern "C"的说明
- 第二天关于telnet远程登录的设置
- Regular Expression Specification
- 改变VC++应用程序各种窗口的标题
- 在C#程序中实现插件架构
- 数据库设计中的反规范技术探讨(zz)
- SPS SmartPart
- SQL SERVER的备份恢复问题,数据库正在使用……
- base64 加密解密函数