如何在C ++预处理器中检测g ++和MinGW? [英] How can I detect g++ and MinGW in C++ preprocessor?

查看:253
本文介绍了如何在C ++预处理器中检测g ++和MinGW?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做类似的操作:

#ifdef GCC
#define GetFunctionName() string("My function name is ") + __PRETTY_FUNCTION__;
#endif

由于我想使用漂亮的 PRETTY_FUNCTION 只支持gnu,据我所知,所以我需要检测,如果我编译g ++和MinGW,我该怎么做?我猜所有我需要知道的是编译器的预处理器定义,就像我下面为Microsoft。

Since I want to use pretty PRETTY_FUNCTION this is only supported by gnu as far as I know so I need to detect if I am compiling for g++ and MinGW, how can I do that? I'm guessing all I need to know are the compiler's preprocessor definitions, like I did for Microsoft below.

#ifdef WIN32
#define LogFuncBegin() gLogger.FuncBegin( __FUNCTION__ );
#define LogFuncEndSuccess() gLogger.FuncEndSuccess( __FUNCTION__ );
#endif



如何在C ++预处理器中检测g ++和MinGW?

How can I detect g++ and MinGW in C++ preprocessor?

推荐答案

您可以使用:

#ifdef __GNUC__
#ifdef __MINGW32__

对于其他宏,您可能会感兴趣此网页显示其他编译器宏

For additional macro's you might be interested in this page which shows other compiler macros

这篇关于如何在C ++预处理器中检测g ++和MinGW?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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