如何在Linux上使用#ifdef _DEBUG? [英] How to use #ifdef _DEBUG on Linux?

查看:551
本文介绍了如何在Linux上使用#ifdef _DEBUG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux C ++上的_DEBUG宏有问题。
我尝试使用以下方式:

I have a problem with _DEBUG macro on Linux C++. I tried to use something like this:

#ifdef _DEBUG
cout << "Debug!" << endl;
#endif

但是当我在IDE中选择调试时,它不起作用。但是,它可以在Windows上运行。
我在Linux上使用Eclipse IDE进行C ++编码。

But it doesn't work when I select Debug in IDE. However it worked on Windows. I use Eclipse IDE for C++ coding on Linux.

推荐答案

如果使用 cmake 将以下内容放入您的顶级 CMakeLists.txt 文件

If you use cmake put the following in your your top-level CMakeLists.txt file

set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG "_DEBUG")

可在 CMake邮件列表

这篇关于如何在Linux上使用#ifdef _DEBUG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆