[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] MHD_Result casting error.
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] MHD_Result casting error. |
Date: |
Thu, 6 Aug 2020 23:28:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Hi Jason,
In C++, the return type must match precisely, while in C an 'int' vs. an
'enum' only causes a warning. MHD recently changed the C API from 'int'
to enum, so to fix the C++ build you must change the return type of
Httpd::handler to 'enum MHD_Result'. That should be all.
Happy hacking!
Christian
On 8/6/20 8:41 PM, Jason Kary via libmicrohttpd wrote:
> Hello,
>
> I’m hoping someone can help me understand how to fix the following error:
>
> /home/jkary/src/xmrig-amd/src/common/api/Httpd.cpp: In member function
> ‘bool Httpd::start()’:
> /home/jkary/src/xmrig-amd/src/common/api/Httpd.cpp:78:66: error: cannot
> convert ‘MHD_Result (Httpd::*)(void*, MHD_Connection*, const char*,
> const char*, const char*, const char*, long unsigned int*, void**)’ to
> ‘MHD_AccessHandlerCallback’ {aka ‘MHD_Result (*)(void*, MHD_Connection*,
> const char*, const char*, const char*, const char*, long unsigned int*,
> void**)’} 78 | m_daemon = MHD_start_daemon(flags, m_port, nullptr,
> nullptr, &Httpd::handler, this, MHD_OPTION_END); | ^~~~~~~~~~~~~~~ | | |
> MHD_Result (Httpd::*)(void*, MHD_Connection*, const char*, const char*,
> const char*, const char*, long unsigned int*, void**) In file included
> from /home/jkary/src/xmrig-amd/src/common/api/Httpd.cpp:25:
> /usr/include/microhttpd.h:2428:45: note: initializing argument 5 of
> ‘MHD_Daemon* MHD_start_daemon(unsigned int, uint16_t,
> MHD_AcceptPolicyCallback, void*, MHD_AccessHandlerCallback, void*, ...)’
> 2428 | MHD_AccessHandlerCallback dh, void *dh_cls, |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~^~ make[2]: ***
> [CMakeFiles/xmrig-amd.dir/build.make:876:
> CMakeFiles/xmrig-amd.dir/src/common/api/Httpd.cpp.o] Error 1 make[1]:
> *** [CMakeFiles/Makefile2:98: CMakeFiles/xmrig-amd.dir/all] Error 2
> make: *** [Makefile:104: all] Error 2
>
> After a few days of experimenting I’m not able to grok the GNU c++
> compiler error. I can see the return type does not match and
> libmicrohttpd.h is expecting ‘MHD_Result (*)’ and some generous folks on
> reddit explained the return type is wrong because "Your function is
> expecting pointer to function, not a pointer to non-static member function.”
>
> I am not quite strong enough in C++ (yet) to understand how to fix this
> issue. I understand the cause but do not know how to fix this error.
>
> Can anyone spend 5 minutes and educate me?
>
> Thanks in advance!
> Jason
>
signature.asc
Description: OpenPGP digital signature