Created attachment 93217 [details] Fix to dnssd callback related mingw compiler errors When compiling KDNSSD with mingw (installed with the Qt installer), I got the following error: C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp: In member function 'void KDNSSD::DomainBrowser::startBrowse()': C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp:52:83: error: invalid conversion from 'void (*)(DNSServiceRef, DNSServiceFlags, uint32_t, DNSServiceErrorType, const char*, void*) {aka void (*)(_DNSServiceRef_t*, unsigned int, unsigned int, int, const char*, void*)}' to 'DNSServiceDomainEnumReply {aka void (__attribute__((__stdcall__)) *)(_DNSServiceRef_t*, unsigned int, unsigned int, int, const char*, void*)}' [-fpermissive] 0, domain_callback, reinterpret_cast<void *>(d)) == kDNSServiceErr_NoError) { ^ In file included from C:\dev\kdnssd\src\mdnsd-responder.h:26:0, from C:\dev\kdnssd\src\mdnsd-domainbrowser_p.h:24, from C:\dev\kdnssd\src\mdnsd-domainbrowser.cpp:21: C:/PROGRA~1/BONJOU~1/Include/dns_sd.h:859:31: note: initializing argument 4 of 'DNSServiceErrorType DNSServiceEnumerateDomains(_DNSServiceRef_t**, DNSServiceFlags, uint32_t, DNSServiceDomainEnumReply, void*)' DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains ^ mingw32-make[2]: *** [src/CMakeFiles/KF5DNSSD.dir/mdnsd-domainbrowser.cpp.obj] Error 1 mingw32-make[1]: *** [src/CMakeFiles/KF5DNSSD.dir/all] Error 2 mingw32-make: *** [all] Error 2 I managed to fix this error by adding DNSSD_API to the callback function declarations. (Patch attached.) I also got another error about the "netinet/in.h" include in mdnsd-publicservice.cpp. I got it working by replacing it with "Winsock2.h" and adding ws2_32 to target_link_libraries. Another way would be to use the functions from QtEndian instead of ntohs/htons to avoid platform specific includes. After these changes I managed to successfully compile KDNSSD with Bonjour.
Hi Calle, Thanks for looking into this and submitting a patch! I unfortunately won't have time to review this patch until the weekend. In the future, I recommend putting patches on reviewboard ( https://git.reviewboard.kde.org/ ) as they get more visibility there (bug reports are always fine here!). If you don't mind, it would be good to put that patch there, but we can merge it in its current form just fine as well :) Thanks again!
According to our CI, kdnssd builds fine with MSVC, see https://build.kde.org/job/Frameworks/job/kdnssd/ Is this still an issue with MinGW?
If you can provide the information requested in comment #2, please add it.
I'm now using GCC 5.5.0 in MXE to build my application and am no longer encountering the first error. I do however get an error about missing "netinet/in.h". Currently, I'm working around this by replacing "netinet/in.h" with <QtEndian> and ntohs and htons calls with qFromBigEndian and qToBigEndian calls.