gpt4 book ai didi

c - 在 C 中使用旧式函数定义在 MinGW 编译器中给出错误

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

我正在研究 dwayne phillips 的 C 图像处理,并使用它的源代码来了解图像处理的基础知识。源代码中的所有功能都以我通常使用的不同风格给出

这里我给出了一个在源代码中给出的正常函数。我使用带有 minGW 编译器的 dev c++ 来编译具有该函数的代码

edm8(in_name, out_name, the_image, out_image,
il, ie, ll, le, value)
char in_name[], out_name[];
int il, ie, ll, le;
short the_image[ROWS][COLS],
out_image[ROWS][COLS],
value;
{
int a, b, count, i, j, k;

create_file_if_needed(in_name, out_name, out_image);

read_tiff_image(in_name, the_image, il, ie, ll, le);

for(i=0; i<ROWS; i++)
for(j=0; j<COLS; j++)
out_image[i][j] = 0;

/***************************
*
* Loop over image array
*
****************************/

printf("\n");

for(i=0; i<ROWS; i++){
if( (i%10) == 0) printf("%3d", i);
for(j=0; j<COLS; j++){
if(the_image[i][j] == value)
out_image[i][j] = distance_8(the_image, i, j, value);
} /* ends loop over j */
} /* ends loop over i */

write_array_into_tiff_image(out_name, out_image,
il, ie, ll, le);

} /* ends edm8 */

现在当我像上面那样编译任何函数时,我得到了这两个错误

 [Error] expected constructor, destructor, or type conversion before '(' token  
[Error] expected unqualified-id before '{' token in

我无法追踪、调试和理解它们产生的原因??

最佳答案

以下消息:[错误] 在“(”标记之前需要构造函数、析构函数或类型转换

让我认为您实际上是在用 C++ 而不是 C 编译。

通过在您的环境中设置正确的构建选项,仔细检查您是否真的使用 C 而不是 C++ 进行编译。许多 IDE 默认编译,C++ 即使文件扩展名为 .c。

关于c - 在 C 中使用旧式函数定义在 MinGW 编译器中给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14301901/

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