如何使用gcc在命令行中取消定义定义 [英] How to undefine a define at commandline using gcc

查看:410
本文介绍了如何使用gcc在命令行中取消定义定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在编译时使用gcc取消定义编译器宏。我尝试了一些编译参数给gcc,像-D,但我无法看到未定义消息。

How do I at compile time undefine a compiler macro using gcc. I tried some compile args to gcc like -D but I can't get to see the "not defined" message.

谢谢

#include <iostream>

#define MYDEF


int main(){
#ifdef MYDEF
  std::cout<<"defined\n";
#else
  std::cout<<"not defined\n";
#endif

}


推荐答案

你可以在gcc中使用-U选项,但它不会取消定义源代码中定义的宏。据我所知,没有办法做到这一点。

You can use the -U option with gcc, but it won't undefine a macro defined in your source code. As far as I know, there's no way to do that.

这篇关于如何使用gcc在命令行中取消定义定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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