i am getting the compile error:
Error 7 error C2084: function 'Boolean IsPointInRect(...)' already has a body
on my inline function, which is declared like this in a cpp file:
inline Boolean IsPointInRect(...)
{
...
}
i have exactly the same function in another cpp file. might this be causing the problem? how can i solve it?
As litb and AndreyT point out, this answer doesn't address the actual problem - see litbs answer for details.
While static
, as Ofir said, gives you internal linkage, the "C++ way" is to use unnamed namespaces:
namespace
{
inline Boolean IsPointInRect(/*...*/) { /*...*/ }
}
§7.3.1.1/1:
An unnamed-namespace-definition behaves as if it were replaced by
namespace unique { /* empty body */ }
using namespace unique;
namespace unique { namespace-body }
where all occurrences of unique in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program.
§7.3.1.1/2 adds:
The use of the static keyword is deprecated when declaring objects in a namespace scope (see annex D); the unnamed-namespace provides a superior alternative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With