问题描述
在使用Visual Studio 2017(准确地说是15.5.6)中的Visual C ++时,我注意到GCC中的__PRETTY_FUNCTION__
似乎有效! -至少在某种程度上……
While playing around with Visual C++ from Visual Studio 2017 (15.5.6 to be exact) I noticed that __PRETTY_FUNCTION__
from GCC seems to work! - to some degree at least…
在输入时确实显示了建议:
It did show up along suggestions while typing:
它的值也按预期显示在工具提示中:
Also it had its value shown in tooltip as expected:
,但是使用__PRETTY_FUNCTION__
编译代码会导致错误:
And yet compiling the code using __PRETTY_FUNCTION__
results in an error:
error C2065: '__PRETTY_FUNCTION__': undeclared identifier
那么,有什么方法可以使其在Visual C ++中运行?也许包括一些?还是一些特殊的编译设置? (我认为我使用的是默认值.)为什么在所示示例中有效,但在实际使用中无效?!
So, is there any way to make it work in Visual C++? Some include perhaps? Or some special compilation settings? (I think I'm using default ones.) Why would it work in shown examples, but not in actual use?!
请注意,我不是在寻找__PRETTY_FUNCTION__
的Visual C ++替代方案.我已经知道了我对这里的行为感到惊讶和好奇.
Note, that I'm not looking for Visual C++ alternatives for __PRETTY_FUNCTION__
. I know them already. I'm just surprised and curious about the behavior here.
推荐答案
否.
Visual Studio将 Edison设计组 C ++前端用于InteliSense,如Visual C ++中所述团队博客的重建Intellisense 和此处,而不是Microsoft C ++编译器.这意味着Intellisense可用的某些功能在编译时不可用.
The Visual Studio uses the Edison Design Group C++ Front End for the InteliSense, as explained in the Visual C++ Team Blog's Rebuilding Intellisense and here, and not the Microsoft C++ compiler. This means that some of the features available to the Intellisense are not available in compile time.
EDG的 C ++前端文档提到其支持某些GCC预定义像第71页的__PRETTY_FUNCTION__
-"1.13预定义的宏"以及Microsoft的__FUNCSIG__
.
EDG's C++ Front End documentation mentions that its supports some of the GCC pre-defines like __PRETTY_FUNCTION__
on page 71 - "1.13 Predefined Macros" together with Microsoft's __FUNCSIG__
.
您甚至可以通过键入__EDG_VERSION__
并将鼠标悬停在其上来查看EDG的版本.
You can even see the version of the EDG by typing __EDG_VERSION__
and hovering over it.
这篇关于在Visual C ++中__PRETTY_FUNCTION__的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!