gpt4 book ai didi

c - 使用gmp编译时出错

转载 作者:行者123 更新时间:2023-11-30 17:56:15 24 4
gpt4 key购买 nike

我在尝试编译使用 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

最佳答案

您只是忘记初始化它。

“这样的变量必须是通过调用 gmp_randinit 函数之一进行初始化,并且可以使用以下函数之一作为种子gmp_randseed 函数。” - 手册第 65 页。

关于c - 使用gmp编译时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13716088/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com