I was working on a project that links to libcrafter (Version 0.2), today. When I build this project with g++ (5.4), there were no problems.
I'm working on switching to clang-8, so I set CC and CXX to clang, clang++ respectively, ran a cmake, and started the build over.
That resulted in the titular error message:
friend declaration of 'ConnectHandler' does not match any declaration in the namespace 'Crafter'
/* Rest of the error message, including the following declaration
* friend void* Crafter::ConnectHandler(void *thread_arg), the line and
* column number, filename etc.
*/
I also got the same error for another function in the code. The errors were indicated in crafter/Utils/TCPConnection.h (line 247, 248).
On checking the header file, I found the friend declarations:
namespace Crafter
{
class TCPBuffer
{
// Stuff
};
class TCPConnection
{
// Other declarations etc.
friend void* Crafter::ConnectHandler(void *thread_arg);
friend void Crafter::PckHand(Crafter::Packet *sniff_packet, void *user);
// Class declaration continues
};
}
And in the TCPConnection.cpp file, I found:
namespace Crafter
{
void* ConnectHandler(void *thread_arg);
void PckHand(Packet *sniff_packet, void *user);
}
// Intervening code
void Crafter::PckHand(Crafter::Packet *sniff_packet, void *user
{
// Do stuff
}
void* Crafter::ConnectHandler(void *thread_arg)
{
// Do stuff
}
This looked okay to me, and my g++ based build offered no complaints. I tried to reproduce this with a minimal working example, but I have been unable to succeed so far: compiles without errors.
An added note is that this error turned up not while building crafter itself, but while building another piece of code that links to it. Specifically, filename.cc
had the TCPConnection.h file included from my project includes directory, and that's where the compiler pointed me.
I would greatly appreciate any help in understanding this error, and resolving it.