我正在尝试使用 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/