I have a namespace with inline function that will be used if several source files. When trying to link my application, the inline function are reported as duplicate symbols. It seems as if my code would simply not inline the functions and I was wondering if this is the expected behavior and how to best deal with it.
I use the following gcc options: -g -Wextra -pedantic -Wmissing-field-initializers -Wredundant-decls -Wfloat-equal -Wno-reorder -Wno-long-long The same code style seems to compile and link properly when build in a VC7 environment.
The following code example shows the structure of the code:
/* header.h */
namespace myNamespace {
inline bool myFunction() {return true;}
}
/* use_1.cpp */
#include "header.h"
...
bool OK = myNamespace::myFunction();
...
/* use_2.cpp */
#include "header.h"
...
bool OK = myNamespace::myFunction();
...