5.2.1.1. scripts/unifdef.c:209:25: error: conflicting types for ‘getline'

错误现象:

cygwin下ct-ng build去编译crosstool-ng出现:


CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build
$ ct-ng build
......
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[ERROR]    /home/CLi/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for 'getline'
[ERROR]    make[3]: *** [scripts/unifdef] Error 1
[ERROR]    make[2]: *** [headers_install] Error 2
[ERROR]    make[1]: *** [headers_install] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing kernel headers'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_kernel_install[scripts/build/kernel/linux.sh@112]
[ERROR]  >>        called from: do_kernel_headers[scripts/build/kernel/linux.sh@91]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]
......

            

原因:

Linux源码中的scripts/unifdef.c中的函数:getline,和别处重复定义了。

此问题,算是一个,很普遍遇到的,很早之前就出现的问题了。

解决办法:

把getline随便改个别的名字,即可。比如改为get_line

具体做法:

去修改对应的文件;

crosstool-ng-1.18.0_build\.build\src\linux-custom\scripts\unifdef.c

改为:


static void             flushline(bool);
//static Linetype         getline(void);
static Linetype         get_line(void);
static Linetype         ifeval(const char **);
 
......
 
/*
 * The driver for the state machine.
 */
static void
process(void)
{
    Linetype lineval;
 
    for (;;) {
        linenum++;
        //lineval = getline();
        lineval = get_line();
        trans_table[ifstate[depth]][lineval]();
        debug("process %s -> %s depth %d",
            linetype_name[lineval],
            ifstate_name[ifstate[depth]], depth);
    }
}
 
/*
 * Parse a line and determine its type. We keep the preprocessor line
 * parser state between calls in the global variable linestate, with
 * help from skipcomment().
 */
static Linetype
//getline(void)
get_line(void)
{

            

即可。

详见:【已解决】crosstool-ng在Installing kernel headers时出错:[ERROR] /xxx/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for ‘getline’