Function in namespace - multiple definition
-
Hi, i cannot figure this out: hpp:
namespace ContractStorage
{
std::string DoIt(ContractName c); // Declaration
}cpp:
namespace ContractStorage
{
std::string DoIt(ContractName c)
{
printf("yes");
}
}It says: multiple definition of `ContractStorage::DoIt(ContractStorage::ContractName)' How can this be, i only have the decalaration in the hpp file? I have a class declaration in the same file, it does not complain about that...
-
Hi, i cannot figure this out: hpp:
namespace ContractStorage
{
std::string DoIt(ContractName c); // Declaration
}cpp:
namespace ContractStorage
{
std::string DoIt(ContractName c)
{
printf("yes");
}
}It says: multiple definition of `ContractStorage::DoIt(ContractStorage::ContractName)' How can this be, i only have the decalaration in the hpp file? I have a class declaration in the same file, it does not complain about that...
-
There must be something else that is causing this that is external to your header file. I just tried that and it compiled without error. Does the error message give you any line numbers?
-
I noticed that the issue only occurs when i use "_" as function name. When i set it to something else it will work. My namespace was named the same as my class, is it possible that the compiler did not detect the ambiguity?
-
Hi, i cannot figure this out: hpp:
namespace ContractStorage
{
std::string DoIt(ContractName c); // Declaration
}cpp:
namespace ContractStorage
{
std::string DoIt(ContractName c)
{
printf("yes");
}
}It says: multiple definition of `ContractStorage::DoIt(ContractStorage::ContractName)' How can this be, i only have the decalaration in the hpp file? I have a class declaration in the same file, it does not complain about that...
Off the top of my head, one thing that may cause this message would be if you #include the header in multiple locations and have no header guards (either pragma once directive or #ifndef/#define/#endif method).