extern c 解释
2024-08-28 19:55:14
extern “C”修饰的变量和函数是按照c的方式编译的
如果想用c++方式编译c代码,需要特殊标识
方法
#if defined(__cplusplus) || defined(c_plusplus)
extern "C"{
#endif
...
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
举例
void func(int a, char b, float c){}
# g++ *.cpp -S
# cat *.s
.file "*.cpp"
.text
.globl _Z4funcicf //func+int+char+float
.type _Z4funcicf, @function
#if defined(__cplusplus) || defined(c_plusplus)
extern "C"{
#endif
void func(int a, char b, float c){}
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
# g++ *.cpp -S
# cat *.s
.file "*.cpp"
.text
.globl func
.type func, @function
最新文章
- java 计算 1到10 的 阶层的和(采用递归的方法)
- Python 批量修改文件名
- MySQL执行计划解读
- postgreSQL绝对值
- quick lua 使用spine骨骼动画
- noip2011普及组——统计单词数
- iOS开发——适配篇&;iOS9适配
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(21)-权限管理系统-跑通整个系统
- HDU - 1116 Play on Words(欧拉图)
- Maven项目pom文件设置JDK版本
- js数据结构与算法--双向链表的实现
- Hadoop学习------Hadoop安装方式之(二):伪分布部署
- James 如何作为服务在后台启动
- git stash错误小记
- BZOJ5371[Pkusc2018]星际穿越——可持久化线段树+DP
- H5使用Swiper过程中遇到的滑动冲突
- jquery ready方法实现原理
- Laravel 5.4 Cache::put的一个小坑
- EF添加Msysql实体异常:表“TableDetails”中列“IsPrimaryKey”的值为 DBNull。 --->; System.InvalidCastException: 指定的转换无效。
- 使用html+css+js实现计算器