使用gmp进行编译时出错

时间:2012-12-05 04:02:58

标签: c compiler-errors gmp

我在尝试编译使用GMP的代码时遇到此错误。有什么办法可以解决这个问题吗?我使用visual studio 2010命令提示符进行编译,这是我使用的命令:

  

cl testing.c gmp.lib

int main(void)
{
    mpz_t a,b;
    mpz_init(b);
    mpz_init(a);
    gmp_randstate_t rstate; // the problem arises when declaring this
}

testing.c
testing.c(9) : error C2275: 'gmp_randstate_t' : illegal use of this type as an e
xpression
        c:\cygwin\home\administrator\ss\gmp.h(252) : see declaration of 'gmp_ran
dstate_t'
testing.c(9) : error C2146: syntax error : missing ';' before identifier 'state'

testing.c(9) : error C2065: 'state' : undeclared identifier
testing.c(11) : error C2065: 'state' : undeclared identifier
testing.c(11) : warning C4047: 'function' : '__gmp_randstate_struct *' differs i
n levels of indirection from 'int'
testing.c(11) : warning C4024: '__gmp_randinit_default' : different types for fo
rmal and actual parameter 1
testing.c(13) : error C2065: 'state' : undeclared identifier
testing.c(13) : warning C4047: 'function' : '__gmp_randstate_struct *' differs i
n levels of indirection from 'int'
testing.c(13) : warning C4024: '__gmpz_urandomb' : different types for formal an
d actual parameter 2
testing.c(14) : error C2065: 'state' : undeclared identifier
testing.c(14) : warning C4047: 'function' : '__gmp_randstate_struct *' differs i
n levels of indirection from 'int'
testing.c(14) : warning C4024: '__gmpz_urandomb' : different types for formal an
d actual parameter 2

1 个答案:

答案 0 :(得分:0)

你忘了初始化它。

“这样的变量必须是 通过调用gmp_randinit函数之一进行初始化,并且可以使用其中一个函数进行种子化 gmp_randseed functions。“ - manual pg 65。