You have to declare an instance in one and
only one place. Then everywhere else the variable is accessed you use the extern modifier.
Another way is to put this definition into a header file. I have it a file called Globals.h :
#ifdef DEFINE_GLOBALS
#define Global
#else
#define Global extern
#endif
Then you include the Globals.h file in all of your modules, prior to declaring in variables. You can also put the global variables in one file. I sometimes do this and call it GlobalData.h. In your case, let's say you want the buffer and the integers to be global variables. I would make a GlobalData.h file and it would look like this :
#include "Globals.h"
Global int fork_socket_fd[2]; Global char fork_buf[1024];
Then, in the file where your main function is you do this :
#define DEFINE_GLOBALS
#include "GlobalData.h"
int main()
...
and all other files that access the global data will have ONLY this :
#include "GlobalData.h"
I do this whenever I need to have global data. I often wrap the global data in a namespace to denote their nature. You can extend the definitions to support initialization if you want to. Here is another definition you can add to Globals.h to do that :
#ifdef DEFINE_GLOBALS
#define GlobalVar(Type,Variable,Value) Type Variable=Value
#else
#define GlobalVar(Type,Variable,Value) extern Type Variable
#endif
As an example, say you had a variable for the color of all text in your app. You can declare it in your GlobalData.h file like this :
GlobalVar( COLORREF, TextColor, RGB(255,255,255) );
and it will be initialized to white and accessible to all modules that include GlobalData.h
-edit-
I DID NOT SEE RICHARD'S ANSWER. Not this time or any other time.