本文介绍了CUDA:NVCC给出控制表达式是断言的常量警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到警告控制表达式是常量
在assert语句如下:
I get the warning controlling expression is constant
on assert statement like this:
assert(... && "error message");
为什么这个警告会出现?如何禁止此警告?
Why this warning on this assert? How can I suppress this warning?
NVCC是NVIDIA cuda编译器,我认为它是基于LLVM的。
NVCC is the NVIDIA cuda compiler, I think it is based on LLVM. Why does it give this warning, when the same compiles fine with GCC or Visual C++ compilers?
推荐答案
一个可移植的替代方案在宏中)将是这样的:
A portable alternative (possibly wrapped in a macro) would be something like:
{
const bool error_message = true;
assert([...] && error_message);
}
清除我的意思:
#define myAssert(msg, exp) { const bool msg(true); assert(msg && (exp)); }
// usage:
myAssert(ouch, a && b);
...例如:
这篇关于CUDA:NVCC给出控制表达式是断言的常量警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!