You got some wrong answers in this thread. The problem in your code is that you define your inline function twice in your code:
inline Boolean IsPointInRect(...) { ... }
inline Boolean IsPointInRect(...) { ... }
inline
will, as someone else said correctly, already protect you from having an error risen by defining the function twice. You don't need static
, nor will you need unnamed namespaces. Also notice that you shouldn't define inline functions that are supposed to be used by other translation units (a file where all #include and #if etc... are processed and expanded) within the .cpp
file. Their definition have to be known by all translation units that use them - so put their definition only in the header file in that case - not in both the .cpp
and the header file - that will yield to the error you get.
You also need header guards to avoid the above problem in each of your headers
// file foo.h
#ifndef POINTS_H_INCLUDED
#define POINTS_H_INCLUDED
inline Boolean IsPointInRect(...) { ... }
#endif
// file bar.cpp
#include "foo.h"
// does not include the content a second time anymore - the guards aboid it:
#include "foo.h"
And you should make sure not to include a .cpp
file into another .cpp
file (.cpp
files are not supposed to be included). You are supposed to include the header files into the .cpp
files.