- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有预处理器宏定义其中的函数名称,__func__
对于 g++ 和 __FUNCTION__
对于 CL。 ( func 是执行此操作的 C++ 标准方法(来自 dcl.fct.def.general),但并未在任何地方实现)
对于将由这两个编译器编译的源代码,我该怎么办?
我试过了
#ifdef __func__
#define FUNCTION_NAME __func__
#else
#ifdef __FUNCTION__
#define FUNCTION_NAME __FUNCTION__
#else
#error "Function name macro not found"
#endif
#endif
void implementation_detail() {
#ifdef __func__
#define FUNCTION_NAME __func__
#else
#ifdef __FUNCTION__
#define FUNCTION_NAME __FUNCTION__
#else
#error "Function name macro not found"
#endif
#endif
}
最佳答案
我发现有一个 boost 宏,BOOST_CURRENT_FUNCTION。
从看源码here这是如何实现的,他们使用这样的内联函数。
inline void current_function_helper()
{
#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) || defined(__DMC__)`
...
关于c-preprocessor - 跨编译器工作的函数名宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20244726/
我正在考虑在某些项目中使用 Boost.Preprocessor,但我不想让整个 Boost 库成为依赖项。 我可以单独复制它并摆脱它吗?否则,它的依赖项是什么? 最佳答案 新答案 我刚刚让 bcp
从我关于 appending to CPP macros 的问题中分离出来: 这里有没有人用过Boost.Preprocessor库的数据类型来实现类似 X 宏的东西? 最佳答案 我只是查了一下 X-
我想用不同的预处理器运行 Karma 几次。基于失败,karma exec 在命令行上监听 --preprocessors,但我无法正确设置它。 以下都返回相同的错误。 karma start --s
我有一个带有预处理器指令的Inno Setup脚本(#define,#if等)。 我想在脚本上运行Inno Setup预处理器,并查看预处理器的输出(以Inno-Setup口语翻译)。也就是说,我要查
在我的项目中,ifdef预处理程序指令中包含一个文件 #ifdef SOME_SYMBOL ... entire file ... #endif SOME_SYMBOL由在此文件之前编译的另一个文件定
在tracing.hh中,我有一组调试宏。它是否生成代码和输出由实际源代码中的宏标志控制: // File: foo.cc #define TRACING 0 #include "tracing.h
我了解 ANN 输入必须标准化、标准化等。 撇开各种 ANN 的特性和模型不谈,在将其作为神经网络的输入之前,如何在 {0,1} 范围内或在 {-1,1} 范围内预处理 UTF-8 编码文本? 我一直
我正在选修数据挖掘本科类(class),并且收到了编写数据挖掘预处理器的作业。我可以自由选择编程语言和数据集。我想知道是否有人可以建议一个好的数据集来使用。我一直在经历UCI Repository我还
当我同时定义两条指令时,如何做到这一点,我会收到编译错误? 在这里我想要错误 #define ENG #define POL #if defined POL #if defined ENG 这里没有
LLVM libc++ 头文件有一个宏,用于函数声明,名为 _LIBCPP_INLINE_VISIBILITY . 我不明白这是什么意思;我查看了它的定义,它说: // Just so we can
我正在使 1991 年的代码在 Ubuntu 19 上运行。 我有这个文件,我需要通过 CPP 运行,我被迫使用 -traditional 选项。 #define ITEM_WEAPON 5 #def
我想使用预处理器注释一行: #define open /##* #define close */ main() { open commented line close } 当我这样做时
我不敢相信我会问这个...... 好久没用VC6了。我设置了我认为是包含文件附加目录的正确方法(我删除了另一个开发人员的硬编码路径)并放入如下内容: %MY_DIR%\包括 但这行不通。我错过了什么吗
有预处理器宏定义其中的函数名称,__func__对于 g++ 和 __FUNCTION__对于 CL。 ( func 是执行此操作的 C++ 标准方法(来自 dcl.fct.def.general),
这个问题已经在这里有了答案: 9年前关闭。 Possible Duplicate: C preprocessor: using #if inside #define? 在define的rhs中包含预处
考虑这个代码: #define N_ 0 #define N_X 1 #define M(a) N_ M(arg)X; // #1 -- I'd like this to expand to
在 C /C++ 有两种类型的宏: #define ABC /* usual */ 和 #define FUNC(a) /*function-like*/ 但是我怎么能取消定义它们呢? 更新
有没有办法在编译时而不是在运行时有条件地做到这一点? “标志”将永远是一个常数。 A() 和 B() 是宏。 #define DEMO(flag, p) if (flag) A(p); else B(
是否有某种方法可以将 pragma 语句与其他语句一起嵌入到宏中? 我正在努力实现以下目标: #define DEFINE_DELETE_OBJECT(type)
是否可以在 C 中编写自定义条件预处理器指令。例如; #define _IF_ (condition, explanation) \ #ifdef condition 每条评论都会很棒,
我是一名优秀的程序员,十分优秀!