First, you need to know what a translation unit includes. A compiler translation unit is a C/C++ file and all of the include files. What this error means is that a function or variable is defined multiple times across different translation units (one way or another). Although many users know how to put function prototypes and variable typedefs within guarded headers, there is often a misunderstanding about what the guard is capable of doing within the header file. For example:
Even with the guards in place, myfile.h is included in both Foo.c and Bar.c. They are independent compilations. The guards only prevents you from including myfile.h more than once in Foo.c.
If you are experiencing errors, you may have:
- missing externs,
- missing typedefs,
- or missing guards definitions (that should not be in a header file).
An example of what one might report follows: