英特尔数学核心函数库在头文件中包含这段代码:
#ifndef MKL_Complex16
typedef
struct _MKL_Complex16 {
double real;
double imag;
} MKL_Complex16;
#endif
如所述此处并讨论了此处,用户可以覆盖此结构定义 写入
#define MKL_Complex16 std::complex<double>
在包含头文件之前 。在这一行中,MKL_Complex16
被#define
'd,这意味着字符串只是被替换为文字字符 std::complex
> 无处不在。如果不是,则对其进行 typedef
编辑,从而为编译器提供更多信息。
这被认为是可接受的做法吗?我想一定是这样,因为它是由英特尔实现的。但我在尝试调试一些代码时发现它非常令人困惑。
The Intel Math Kernel Library contains this bit of code in a header file:
#ifndef MKL_Complex16
typedef
struct _MKL_Complex16 {
double real;
double imag;
} MKL_Complex16;
#endif
as described here and discussed here, this struct definition can be over-ridden by the user by writing
#define MKL_Complex16 std::complex<double>
before the header file is included. With this line, MKL_Complex16
is #define
'd, which means the character string is just replaced with the literal characters std::complex<double>
everywhere. If not, it is typedef
'ed, which gives the compiler more information.
Is this considered acceptable practice? I guess it must be, since it's implemented by Intel. But I found it very confusing while trying to debug some code.
发布评论
评论(1)
这看起来很疯狂。我非常不愿意通过构建环境传递实际代码。如果有的话,请使用更高级别的标志:
This looks insane. I would be very reluctant to pass actual code through the build environment. If anything, use a higher-level flag: