【发布时间】:2020-04-20 21:10:00
【问题描述】:
我在我的头文件 aba.h 中声明了 2 个 termios 结构:
extern struct termios cookedInput, rawInput;
然后在一个函数中,我尝试更改 stdin_prep.c 中的值,如下所示:
tcgetattr(STDIN_FILENO, &cookedInput);
rawInput = cookedInput;
cfmakeraw(&rawInput);
gcc -Wall -Werror -Wextra *.c 给我以下错误:
In function stdin_change.c
stdin_change.c:(.text+0x26): undefined reference to 'rawInput'
stdin_change.c:(.text+0x55): undefined reference to 'cookedInput'
stdin_prep(); 和 stdin_change("raw"); 这些函数在我的main.c 中调用。
我尝试了以下几种解决方案: Undefined reference to global variable during linking 和 C: undefined reference to a variable when using extern 但得到了一堆不同的错误。
我已经附上了我的终端的图片。 WSL-Ubuntu-18.04-Screenshot
【问题讨论】:
标签: c gcc extern undefined-reference termios