Linker Error on having non Inline Function defined in header file?

c++, definition, function, header

Solution

If the header is included in more than one source file and the function is not marked as "inline" you will have more than one definition. The include guards only prevent multiple inclusions in the same source file.

Problem

Non inline function defined in header file with guards ``` #if !defined(HEADER_RANDOM_H) #define HEADER_RANDOM_H void foo() { //something } #endif ``` Results in linker error : Already defined in someother.obj file Making the function inline works fine but I am not able to understand why the function is already erroring out in first case.

Original source

Related problems