Quantcast
Viewing all articles
Browse latest Browse all 22117

How do I assign values to or modify an extern struct declared in C header file?

I declared 2 termios structs in my header file aba.h:

extern struct termios cookedInput, rawInput;

And then in a function I tried to changed the values in stdin_prep.c like so:

tcgetattr(STDIN_FILENO, &cookedInput);rawInput = cookedInput;cfmakeraw(&rawInput);

gcc -Wall -Werror -Wextra *.c gives me the following errors:

In function stdin_change.cstdin_change.c:(.text+0x26): undefined reference to 'rawInput'stdin_change.c:(.text+0x55): undefined reference to 'cookedInput'

Those functions stdin_prep(); and stdin_change("raw"); are called in my main.c.

I've tried a few solutions from:Undefined reference to global variable during linking and C: undefined reference to a variable when using extern but got a bunch of different errors.

I've included a picture of my terminal.WSL-Ubuntu-18.04-Screenshot


Viewing all articles
Browse latest Browse all 22117

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>