2011-09-01 41 views
0

我想将无符号整型*(也定义为std :: size_t)类型的指针传递给MKL函数,该函数期望它是long long *是64位整数,我得到类型不兼容性错误。我在64位整数模式下使用MKL。任何帮助? 谢谢在C++中使用指向无符号长整型而不是长长整型的指针

+1

任何原因你不只是施放它?请注意,如果这样做,您可能需要首先检查溢出并在必要时截断它。 – Kevin

+0

谢谢凯文。这解决了这个问题。我如何检查溢出? – Tarek

回答

0
#include <limits.h> 

int main() { 
    unsigned int i = UINT_MAX; 
    unsigned int iptr = &i 

    // In writing this, I realized that you have to change the original 
    // or declare a new llong, but remember that 
    // returning a pointer to a local is bad. Change the original if you can. 
    if(i > LLONG_MAX) i = LLONG_MAX; 
    long long *lptr = (long long *)i; 
}