It's UWAweek 52

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 1168 articles.
Currently 1 other person reading this forum.


 UWA week 39 (2nd semester, week 9) ↓
SVG not supported

Login to reply

👍?
helpful
10:39am Tue 26th Sep, Christopher M.

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.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy