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


    If I understand you correctly, you mean that your header file has things in
it
like:

int    globalvar1;

If that's what you mean, it's not good practice, and most compilers won't
allow it.  A better way is to declare the variables external in the .h file,
and place the variables themselves in s single module that is compiled and
linked with your other c files.  Some c compilers will let you do the kind
of thing I mentioned above, but most won't.

Speaking only for myself,

Joe Durusau


dave 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?
>
> Thanks again.
>
> --
> -Dave


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