2012-12-05 72 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.