2012-12-05 6 views
0

GMP를 사용하는 코드를 컴파일 할 때이 오류가 발생합니다. 이 문제를 해결할 수있는 방법이 있습니까? 임 컴파일 비주얼 스튜디오 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.

관련 문제