Re: Split into several .c files -> where to put the global variables?
From: Ralf Fassel (ralfixx_at_gmx.de)
Date: 09/07/05
- Next message: Casper H.S. Dik: "Re: does the accept system call always return the lowest file descriptor"
- Previous message: Patricia: "Re: Is there a tool or compiler option to make program crash as soon as access memory illegally"
- In reply to: Alexander Farber: "Split into several .c files -> where to put the global variables?"
- Next in thread: David Schwartz: "Re: Split into several .c files -> where to put the global variables?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 07 Sep 2005 11:34:02 +0200
* "Alexander Farber" <Alexander.Farber@gmail.com>
| Should I keep the variables in the main token-server.c and put the
| "extern" declarations into token-server.h?
That's the usual way this is done. You need the declaration in every
source file which uses the global variable, and the definition in
exactly one source file. You can play tricks with the preprocessor in
the header file, but in my experience it is cleaner if you maintain
the double list. If you get it wrong, the compiler will complain
anyway.
R'
- Next message: Casper H.S. Dik: "Re: does the accept system call always return the lowest file descriptor"
- Previous message: Patricia: "Re: Is there a tool or compiler option to make program crash as soon as access memory illegally"
- In reply to: Alexander Farber: "Split into several .c files -> where to put the global variables?"
- Next in thread: David Schwartz: "Re: Split into several .c files -> where to put the global variables?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|