gpt4 book ai didi

变量声明冲突,类型重新声明

转载 作者:太空宇宙 更新时间:2023-11-04 02:02:22 26 4
gpt4 key购买 nike

我有这些错误和警告...我对编程很陌生,我不知道这意味着什么。你们能看看这个并告诉我我做错了什么吗?

提前致谢

错误和警告:

Looplicht v2.0.c:226: warning: (361) function declared implicit intLooplicht v2.0.c:237: error: (984) type redeclaredLooplicht v2.0.c:237: error: (1098) conflicting declarations for variable "integer_reverse" (Looplicht v2.0.c:237)

code with errors (I have placed the linenumbers of the errors in the description):

void mode_single_right() {

output_integer = 0x0001; //start right

for (unsigned char i = 0; i < number_of_outputs; i++) {
if (jump) {
jump = 0;

output_integer = integer_reverse(output_integer); //line 226
switch_outputs(output_integer);
output_integer = (output_integer << 1);
} else {
i--;
}
}


}

unsigned int integer_reverse (unsigned int input_br) { //line 237

unsigned int output_br = 0;
bit bit_in_reverse = 0;

for (unsigned char ibr = 0; ibr < 16; ++ibr) {

bit_in_reverse = input_br & 0x01;
output_br |= bit_in_reverse;
input_br >>= 1;
output_br <<= 1;
}
return output_br;
}

最佳答案

您应该在调用函数之前声明它。在第 226 行之前的某个位置(最好是在任何函数之外),包含一个原型(prototype):

unsigned int integer_reverse( unsigned int input_br );

如果调用未声明的函数,在 C89 中,编译器假定声明为:

int integer_reverse();

然后它遇到你的函数头(它是原型(prototype)格式,所以它算作一个原型(prototype))并且编译器检测到这个原型(prototype)与你原来的隐式声明不兼容。

关于变量声明冲突,类型重新声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25664483/

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