I try to declare a global variable config
:
//general.h
struct config_t {
int num;
};
extern struct config_t config; //The global variable
Then I define config variable in general.c
:
//general.c
#include "general.h"
struct config_t config = {
num = 5;
};
But, when I try to use the global variable 'config' in my main function, I get the error:
undefined reference to `config':
Main program:
//main.c
#include "general.h"
main() {
config.num = 10;
}
Why is it?