next up previous contents
Next: Optimisation and Accuracy Up: C Programming for Research. Previous: Monsters from the If   Contents

Header Files and General Tips

Always remember to include the ``math.h" file at the top of any C file which includes transendental functions (sin, cos, sqrt etc.). Otherwise the compiler will (rather uselessly) assume that these return integers.

Try to avoid multiple level header files, they make software interpretation difficult.

When modifying library .c files, do not attempt to re-define functions away from the file they were originally defined in. Most C compilers and linkers will complain about this. If you must create a new .c file then change the function name.

Most linkers check that function prototypes agree with the function call, but do not check the function declaration itself 2.3. All function prototypes for functions within a c file (mycode.c) should be placed in a header file (mycode.h) which should be included at the top of the c file. The compiler will then check that the function prototypes are consistent with the function definition.


next up previous contents
Next: Optimisation and Accuracy Up: C Programming for Research. Previous: Monsters from the If   Contents
root 2017-11-18