Often I create a header file for "main", even if I do not expect other code to have access to it, since often either (1) building the debugging ultimately requires something outside the main module, to access something either in it, or (2) the main module ultimately needs to be split due to compiler (embedded system) limitations. The presence template for each .c file includes its own .h file, strong enough that I often create almost-empty .h files even for .c files that define things that are not referenced in the code (for example, interrupt interception tables and etc.).
Naming conventions become a little more complicated when a file contains several files generated by the program, or includes files that need to be compiled more than once (for example, one of my projects has two engines whose code is identical, except that they use different I / O and various variables, my motor.c file contains:
#define LOCK L0
#include "motor.i"
#undef LOCK
#define LOCK L1
#include "motor.i"
#under lock
Note that on this built-in compiler, the โ operator is very inefficient, so an operator like:
L0.speed ++;
will compile with one instruction, and an instruction like:
L0-> speed ++;
will be transferred to five teams if โspeedโ is the first element in the structure, or seven if it takes any other position. Thus, a much more efficient speed and slightly more efficient area to duplicate a code with constant resolvable addresses than having one manual processing of both engines.
If there is an additional file associated with the .c file and it contains real code, I will call it ".i". Not sure what to do if there is more than one.
supercat
source share