gcc与__cplusplus宏
来源:互联网 发布:淘宝店铺装修招牌图片 编辑:程序博客网 时间:2024/06/05 11:43
__cplusplus宏标志编译器会把代码按C还是C++语法来解析,gcc是没有定义改宏的,而g++却定义了。
[xxx@localhost test]$ [mapan@localhost test]$ lstest.c[xxx@localhost test]$ cat test.c #include<stdio.h>#ifdef __cplusplusint a=1;#endifint main(){ printf("a=%d\n",a); return 0;}[xxx@localhost test]$ gcc test.c test.c: In function ‘main’:test.c:9: error: ‘a’ undeclared (first use in this function)test.c:9: error: (Each undeclared identifier is reported only oncetest.c:9: error: for each function it appears in.)[xxx@localhost test]$ g++ test.c [xxx@localhost test]$ ./a.out a=1[xxx@localhost test]$
结果一目了然。
阅读全文
0 0
- gcc与__cplusplus宏
- __cplusplus宏
- __cplusplus与extern "C"
- __cplusplus与extern "C"
- gcc中用于预编译的宏(如__cplusplus , __func__ , __FILE__ , __LINE__ 等)
- 使用__cplusplus宏
- 使用__cplusplus宏
- __cplusplus
- __cplusplus
- __cplusplus
- __cplusplus
- __cplusplus
- __cplusplus
- __cplusplus
- 宏__cplusplus/////if define…
- 嵌入式 #ifdef __cplusplus与extern "C" { #endif 的解
- gcc 线程模型与宏常量查看
- 编译器 内置宏 并且 支持不同c++标准,__cplusplus不同
- VS2010 教程:创建一个 WPF 应用程序 (第一节)
- 中国剩余定理 [mi不互质]
- ios UICollectionViewCell个数小于等于3,顺序错位
- Numpy 布尔索引
- SpringCloud分布式开发五大神兽
- gcc与__cplusplus宏
- 方法的覆盖(重写)
- "大数据如何帮助小数据?" 主题报告速记与评述(二)
- 常见的eclipse的一些快捷键
- 安装CUDA流程
- Shape图形
- 三大经典排序
- 记17年暑假训练
- EU4-13: Running a meeting