Re: Split into several .c files -> where to put the global variables?
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
- Re: Newbie: structs in vectors
... How/where do I define a constructor function? ... He meant seperate your declarations from your definitions. ... you can define the constructor in it's source file Total.cpp with an ...
- Re: cout << char*
... "Igor Tandetnik" wrote: ... Each source file is ... Including CLib.h in library.cpp is adding the declarations to the definitions. ... int id ...
- Re: Clunky C cleanup code
... MPJ ... > other than main near the top of the source file, ... the declarations should be in a separate ... Thanks all for correcting my correction, ...
- Re: Utility to ensure appropriate headers were included
... a header file that's included directly in the source file? ... that utility is called a C compiler. ... He's not talking about missing declarations. ... declarations that depend on a header that is included indirectly by ...
- Re: Ahead of "main"?
... The latter style is effectively required when you move to multi-file projects, and the standard practice is to put all of your function declarations in header files so that each source file can simply #include the appropriate header files and then use whatever functions are needed. ... Actually, you should not put *all* your function definitions in header files, since generally there are some which should be local to a given source file and declared static in that source file. ...