我想在我的Debian 64位环境中构建32位应用程序.
所以,我正在尝试编译Qt源以获得32位库.
我正在尝试使用以下configure命令:
./configure -platform linux-g++-32
Run Code Online (Sandbox Code Playgroud)
不幸的是,我收到如下错误:
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
Run Code Online (Sandbox Code Playgroud)
但是当我做以下事情时:
./configure -platform linux-g++-64
Run Code Online (Sandbox Code Playgroud)
它工作正常.
任何猜测?
所以我有这个模板功能.它应该在一个更复杂的结构中设置一个变量AbstractEvent:
template< typename T >
void AbstractEvent::setVar( QString varName, T value)
{
if (std::is_pointer<T>::value)
{
void * castValue = static_cast<void*>(value);
if (castValue)
{
//do sth with castValue
}
}
else
{
//do something with value
}
}
Run Code Online (Sandbox Code Playgroud)
使用此模板函数,我想将变量"value"存储在QVariant中,然后将QVariant存储在某处.
如果"value"是指针,我想将它作为void*存储在QVariant中.对于其他任何我想存储真实类型的东西.
我尝试使用C++ trait std :: is_pointer :: value来检查value是否为指针.
这段代码编译得很好,但是当我尝试使用它时,例如:
int intValue = 0;
setVar<int>("aVar",intValue);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error C2440: 'static_cast' : unable to convert from 'int' to 'void *'
Run Code Online (Sandbox Code Playgroud)
我认为编译器很困惑,因为它正在检查这一行:
void * castValue = static_cast<void*>(value);
Run Code Online (Sandbox Code Playgroud)
当值不是指针时,这当然没有意义.这就是我的if语句
if (std::is_pointer<T>::value)
Run Code Online (Sandbox Code Playgroud)
应该避免,但是,即使在运行时,这段代码的值作为int将永远不会被执行,在编译时它会混淆编译器......是否有解决这类问题的方法?