使用当前 gcc 编译 som_pak (97)

标签 c gcc compiler-errors som

我正在尝试使用 Kohonen 的原始 som 实现,但我在使用 vcal 时遇到了段错误。

事实证明,您可以使用非官方版本来纠正在 http://cis.legacy.ics.tkk.fi/hynde/lvq/ 但它是从 1997 年开始的,我确信 cc 编译器有很多变化,所以我收到了这个错误


    checo@canija:~/bin/som/som_pak-3.2$ make
    gcc -O2   -c -o vcal.o vcal.c
    In file included from datafile.h:28,
                     from vcal.c:26:
    fileio.h:69: error: conflicting types for ‘getline’
    /usr/include/stdio.h:651: note: previous declaration of ‘getline’ was here
    make: *** [vcal.o] Error 1
    checo@canija:~/bin/som/som_pak-3.2$ 

文件datafile.h


    1:#ifndef SOMPAK_DATAFILE_H
    2:#define SOMPAK_DATAFILE_H
    ...
    24:#include 
    25:#include 
    26:#include "lvq_pak.h"
    27:#include "errors.h"
    28:#include "fileio.h"

我能做些什么来重新完成这段代码吗?

最佳答案

将评论转换为答案以解决问题。

getline() 现在是 POSIX 函数;那不是在 1997 年。你最好的选择可能是重命名 fileio.h 中的函数。以及它的使用位置,可能就像在 getline 出现之前添加一样简单在 #include <stdio.h> 之后.

#undef getline
#define getline(a, b, c) som_getline(a, b, c)

使用正确数量的参数,或者

#define getline(...) som_getline(__VA_ARGS__)

如果<stdio.h>尚未包含,然后添加它以确保 getline()正常声明,然后由您的宏映射。

关于使用当前 gcc 编译 som_pak (97),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23690345/

相关文章:

c - 多字符串连接

c - #include – 从 <> 切换到 ""后构建失败

c - 对于 'C' 程序,常量局部变量数组在内存中的位置

c++ - vector 类型不完整(C++ 17)的编译错误

c - 从文本文件读取行到结构 C

java - JNI下C程序编译报错

c++ - 在 Sublime Text 3 中编写 C++ 时出现多个错误

java - 尝试传递二维数组时出现不兼容类型错误

java - @Override 编译报错,实现一个接口(interface)(eclipse jdk1.6.0_23 linux)

c - 在 Sublime Text 3 中构建和运行 C 时的警告消息