I’ve already searched something abou this but I’ve still don’t understand it..
file1.h
extern int *game_array[5];
Player.c
#include "file1.h"
void *delete_player(player_struct *player)
{
... //some code
game_array[5] = 5; //undefined reference to `game_array`
... //some code
}
When I don’t use extern it “work’s fine” = I can build it withou errors, but the program’s not finished ..
I suppose the using extern is fine but something is wrong ..
I want to use this game_array … array of games on server from all my .c source files, there’s only one instance of this array in my aplication.
You need to define
game_arrayin one of your.cfiles, and compile/link that file into your executable.The definition will look like this:
What your
file1.his saying is basically “There exists a variable calledgame_arraysomewhere in my project, and it has such-and-such type”. However, the variable doesn’t actually exist until you’ve defined it somewhere (typically, in a.cfile).