This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Header compilation


On Tue, 31 Aug 1999 10:51:38 -0400, "dave" <a@b.c> wrote:

>Thank you for your help.  One more for you.  I made a header file with a few
>types and global variables of those types.  When I use this header in a .c
>file, I would need to redeclare all variables I intend to use with "extern"
>correct?

Joe gave you a few pointers ... but what do you mean by "use this header" ... do you mean
INCLUDE it with a #include directive?

If you have multiple source modules, many compilers will allow you to #include the same
header file in different modules AS LONG AS THE VARIABLE DECLARATIONS ARE NOT INITIALIZED
AND ARE NOT STRUCTS!  If the variables are initialized or are structs, you can declare them
one and only one time, so if they are in a header file, that file can only be included in
ONE place.  I make a separate header file for my inited vars and structs.  Include it in
your "main" module, and put those variables declared "extern" wherever else you need them.

But then, I never claimed to be a programmer.  It's amazing what some hardware engineers
have to do to make a living!



All the best, and ENJOY!

Art Du Rea
Knoxville, Tennessee, USA

(Remove NOGI:NOGO for direct e-mail)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]