widechar - Linux 上 __FUNCTION__ 的宽版本

标签 widechar

有什么方法可以打印__FUNCTION__作为 linux 上的宽字符?

WIDEN 的技巧对我不起作用,gcc 编译器打印:
错误:?L_FUNCTION_?在这方面没有申明

有什么帮助吗?
谢谢

最佳答案

7 年后(虽然事情似乎是一样的)......

既然你提到了 gcc,检查 [GNU.GCC]: Standard Predefined Macros ( 重点 是我的):

C99 introduced __func__, and GCC has provided __FUNCTION__ for a long time. Both of these are strings containing the name of the current function (there are slight semantic differences; see the GCC manual). Neither of them is a macro; the preprocessor does not know the name of the current function.



__功能__ 不是宏(预处理器不“知道”任何关于它的信息),它在(外部)宏扩展期间将保持不变,最后生成 L__FUNCTION__标识符,这显然是无效的。这就是为什么双宏方法适用于 __文件__ (例如),但不适用于 __功能__ (或 __func__ )。

因此,对您的问题的简短回答是“ NO ”(至少 而不是 在预处理器级别)。您需要转换 __功能__ “手动”(例如,使用 [man7]: MBSTOWCS(3) 函数系列之一)。

备注 :它适用于 VStudio,因为根据 [MS.Docs]: Predefined Macros ( 重点 仍然是我的):

  • __FUNCTION__ Defined as a string literal that contains the undecorated name of the enclosing function. The macro is defined only within a function.

关于widechar - Linux 上 __FUNCTION__ 的宽版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4773941/

相关文章:

delphi - Delphi 中不兼容的 char 和 widechar

c++ - 如何将 wchar_t 转换为 int 以显示代码点?

c++ - 获取进程句柄名称

python - 测试可转换字符的 wchar_t*

c - gcc 在调用 `mbtowc()` 时如何决定宽字符集?

c++ - 混合 std::wcout 和 std::cout 会出错,有什么问题吗?

c++ - 千分之一符号 (‰) 上的 wctomb 扼流圈

c - Widechar 排序并从文件加载

c - 在 C 中使用 wcslen 时出现段错误