ANONYMOUS wrote:
> I was just curious about what the conventions for writing a header file are (i.e., what is acceptable what isn't)? For example, is it unconventional to write more than just variable declarations within a header file. If I write a method within a header file is that acceptable? If so, are there certain contexts or scenarios in which a custom header file should be just variable declarations or methods etc.
Firstly (as we're discussing C), we speak of functions, not methods.
Header files should contain globally-required preprocessor tokens and macros, and *declarations* of functions and variables. These simply *inform* the files that #include the header file that these things *exist*, but does not allocate any memory or code for them.
These issues are more than just convention - for example, if you *defined* a function or a variable in a header file, and if multiple other C files #include-d that header file, then there'd be multiple definitions/implementations of the functions or variables within the same project.