当前位置:网站首页>【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
2022-08-05 01:56:00 【隨意的風】
vs预处理器定义的牛逼写法!!!!
1.问题概述
- 今天组内小伙伴在调试算法接口时,总是在算法接口崩溃,发现vs提示信息为vector too long…结果算法人员告诉设置预编译器定义
_HAS_ITERATOR_DEBUGGING=0取消该宏定义。我擦,这是什么骚操作,还行这么玩,一看就感觉有问题,结果为了证明这样是取消不了该宏的定义的,特此进行了一下验证;
2. main.cpp源代码(vs2017环境,其他vs环境都可以):
#ifdef _HAS_ITERATOR_DEBUGGING
#define x_1 1
#pragma message ("#define x_1 1")
#endif
#ifdef _HAS_ITERATOR_DEBUGGING
#define y_1 1
#pragma message ("#define y_1 1")
#endif
#include <iostream>
int main()
{
//int x = 0;
#ifdef _HAS_ITERATOR_DEBUGGING
{
printf("#ifdef _HAS_ITERATOR_DEBUGGING\n");
printf("x_z = %d\n", _HAS_ITERATOR_DEBUGGING);
printf("x_1 = %d\n", x_1);
printf("y_1 = %d\n", y_1);
}
#endif
if (_HAS_ITERATOR_DEBUGGING == 0)
{
printf("if (_HAS_ITERATOR_DEBUGGING == 0)\n");
printf("x_z = %d\n", _HAS_ITERATOR_DEBUGGING);
printf("x_1 = %d\n", x_1);
printf("y_1 = %d\n", y_1);
}
if (_HAS_ITERATOR_DEBUGGING == 1)
{
printf("if (_HAS_ITERATOR_DEBUGGING == 1)\n");
printf("x_z = %d\n", _HAS_ITERATOR_DEBUGGING);
printf("x_1 = %d\n", x_1);
printf("y_1 = %d\n", y_1);
}
if (_HAS_ITERATOR_DEBUGGING == 2)
{
printf("if (_HAS_ITERATOR_DEBUGGING == 2)\n");
printf("x_z = %d\n", _HAS_ITERATOR_DEBUGGING);
printf("x_1 = %d\n", x_1);
printf("y_1 = %d\n", y_1);
}
// printf("%d\n", vtkBooleanMacro(x,=,1));
std::cout << "Hello World!\n";
getchar();
}
3. 预处理器定义为_HAS_ITERATOR_DEBUGGING=0
3.1 查看重新编译log
- 该宏被编辑器预定义
_HAS_ITERATOR_DEBUGGING 为 0,但是该_HAS_ITERATOR_DEBUGGING还是属于被预定义状态;
3.2 查看运行结果
#ifdef _HAS_ITERATOR_DEBUGGING判断已经被预定义,或者使用if(_HAS_ITERATOR_DEBUGGING == 0/1)这种骚操作很少,起不到取消该_HAS_ITERATOR_DEBUGGING的定义
4. 预处理器定义为_HAS_ITERATOR_DEBUGGING=1

4.1 查看重新编译log
- 该宏被编辑器预定义
_HAS_ITERATOR_DEBUGGING 为 1,但是该_HAS_ITERATOR_DEBUGGING还是属于被预定义状态;
4.1 查看运行结果

5. 预处理器定义为_HAS_ITERATOR_DEBUGGING=2

5.1 查看重新编译log
- 编译阶段直接报错,如图;


6. 总结
- 只要在预处理器界面中定义了
_HAS_ITERATOR_DEBUGGING宏,即编辑器在编辑阶段便会定义该宏。一般不会再对该宏执行=赋值操作(应该是认知错误,想取消该宏的定义); - 如果真的想玩骚操作、乱七八糟非正常设置,那么也只能设置为0/1(很少有这么使用的);而且在程序中也只能使用
if(_HAS_ITERATOR_DEBUGGING == xxxx)等形式进行判断,#ifdef _HAS_ITERATOR_DEBUGGING永远都是有效的,被预定义的宏; - 想取消某个宏的设置,配置成
_HAS_ITERATOR_DEBUGGING=0是起不到取消宏定义作用的;真的想取消还是要去除该宏的配置;
边栏推荐
- SAP ERP和ORACLE ERP的区别是哪些?
- Short domain name bypass and xss related knowledge
- 2022 EdgeX中国挑战赛8月3日即将盛大开幕
- 用@Mapper查询oracle的分区情况报错
- 第十四天&postman
- std::string::find 返回值的坑
- Are testing jobs so hard to find?I am 32 this year and I have been unemployed for 2 months. What should an older test engineer do next to support his family?
- 详细全面的postman接口测试实战教程
- How to deal with your own shame
- 【PyQT5 绑定函数的传参】
猜你喜欢

没有对象的程序员如何过七夕

测试工作这么难找吗?今年32,失业2个月,大龄测试工程师接下来该拿什么养家?

【Word】Word公式导出PDF后出现井号括号#()错误

Are testing jobs so hard to find?I am 32 this year and I have been unemployed for 2 months. What should an older test engineer do next to support his family?

Use of pytorch: Convolutional Neural Network Module

树形查找(二叉查找树)

LPQ (local phase quantization) study notes

从一次数据库误操作开始了解MySQL日志【bin log、redo log、undo log】

CPDA|运营人如何从负基础学会数据分析(SQL)
![[Redis] Redis installation under Linux](/img/84/7791a87ff976be15b455f6ddc05bf2.png)
[Redis] Redis installation under Linux
随机推荐
C语言基础知识 -- 指针
Object.defineProperty实时监听数据变化并更新页面
释放技术创新引擎,英特尔携手生态合作伙伴推动智慧零售蓬勃发展
跨域解决方案
A new technical director, who calls DDD a senior, is convinced
直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计
How to create an rpm package
(17) 51 MCU - AD/DA conversion
.Net C# Console Create a window using Win32 API
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
【Endnote】Word插入自定义形式的Endnote文献格式
Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
sql语句多字段多个值如何进行排序
LPQ (local phase quantization) study notes
多线程涉及的其它知识(死锁(等待唤醒机制),内存可见性问题以及定时器)
硬实力和软实力,哪个对测试人来说更重要?
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
10年测试经验,在35岁的生理年龄面前,一文不值
[parameters of PyQT5 binding functions]
GC高德坐标和百度坐标转换