c++ - Visual C++ 中的 __PRETTY_FUNCTION__

标签 c++ visual-studio visual-c++ visual-studio-2017

在 Visual Studio 2017(确切地说是 15.5.6)中使用 Visual C++ 时,我注意到 GCC 中的 __PRETTY_FUNCTION__ 似乎可以工作! - 至少在某种程度上……

它确实在输入时出现了建议: enter image description here

它的值也如预期的那样显示在工具提示中: enter image description here

但是使用 __PRETTY_FUNCTION__ 编译代码会导致错误:

error C2065: '__PRETTY_FUNCTION__': undeclared identifier

那么,有什么方法可以让它在 Visual C++ 中工作吗?有些可能包括?或者一些特殊的编译设置? (我想我使用的是默认值。)为什么它在所示示例中有效,但在实际使用中却无效?!

请注意,我不是在寻找 __PRETTY_FUNCTION__ 的 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?!

没有。

Visual Studio 使用 Edison Design Group InteliSense 的 C++ 前端,如 Visual C++ 团队博客的 Rebuilding Intellisense 中所述和 here ,而不是 Microsoft C++ 编译器。这意味着 Intellisense 可用的某些功能在编译时不可用。

EDG 的 C++ Front End documentation提到它支持一些 GCC 预定义,例如第 71 页的 __PRETTY_FUNCTION__ - “1.13 Predefined Macros”以及 Microsoft 的 __FUNCSIG__

您甚至可以通过输入 __EDG_VERSION__ 并将鼠标悬停在上面来查看 EDG 的版本。

关于c++ - Visual C++ 中的 __PRETTY_FUNCTION__,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48857887/

相关文章:

c++ - 添加小部件不起作用

c++ - 如果没有线程在等待并且发送了条件信号会怎样?

visual-studio - 如何让 Visual Studio 在每个文件的顶部添加开源许可证

C++ windows.h 在 Windows 10 上包含错误

c++ - 从 vc++ 中的 LPTSTR 获取目录名称

c++按元素编辑txt文件

c++ - 为什么这段代码不能编译?

c# - 过多调试输出 "Event X was called with Y arguments, but it is defined with Z parameter(s)"的解决方法

python - 使用 Visual Studio 2015 安装 python 包时出错

c++ - 无符号/有符号不匹配