Non-inline function defined in a header
ID |
c.maintainability.definitions_in_headers |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
medium |
Remediation Effort |
medium |
Resource |
Header Hygiene |
Language |
C / C++ |
Description
Non-inline function $FN is defined in a header. Including this header from more than one translation unit produces duplicate external definitions and a linker "multiple definition" error. Move the definition to a .c/.cpp file and leave only the declaration in the header, or mark the function inline (C++/C99) if it must stay header-only.
Rationale
Non-inline function $FN is defined in a header. Including this header from more than one translation unit produces duplicate external definitions and a linker "multiple definition" error. Move the definition to a .c/.cpp file and leave only the declaration in the header, or mark the function inline (C++/C99) if it must stay header-only.