2012-12-05 74 views
0

尝试编译我使用GMP的代码时出现此错误。有什么办法可以解决这个问题吗?即时通讯使用Visual Studio 2010的命令提示符下进行编译,这是我用过的命令:使用gmp编译时出错

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 
+0

你应该包括你的实际代码。 –

+0

为什么在cygwin下使用头文件来编译VC++? –

+0

已添加源代码,它被放置在cygwin文件夹中作为临时文件。它对代码没有影响,即使我把它移出了cygwin文件夹 – user1758596

回答

0

你只是忘了初始化。

“这样的变量必须是 通过向的gmp_randinit功能之一的呼叫初始化,并且可以与的 gmp_randseed功能之一接种”。 - 手册页65.