New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile of newer mosquitto versions fail for systems with non recent compilers #2419
Comments
After some googling it seems that the problem is, that there is indeed a difference in the definition in pthread's pthread.h and mosquitto's dummythread.h. While pthread and ulibc(-ng) define |
There's no problem with the definition in dummythread. The problem is that your system imports pthread.h after dummythread has tired to stub out all the pthread methods. What the error is saying is that you've got a macro defined to take no arguments, but you're calling it with an argument. The "call" in this case is actually intended to be the definition of a C function of the same name which takes no arguments. You can make it stop failing at that point by definition the macro to take an argument, but then the macro definition won't match the C function definition, and I'd expect compilation to fail at the spot where pthread_testcancel() is actually called in the code, since it has no arguments there. This is different from the stack-overflow discussion, which is not about macro definitions at all. I'd suggest trying to build with this change to mosquitto_internal.h:
which bypasses dummypthread outright, but might cause other problems because there's a lot of code that does things differently when BROKER is defined, and that might include some data structure initialisation. |
Thanks for your explanation @ptjm but I don't understand where this C function is that doesn't take arguments: In both glibc and uClibc/uClibc-ng sources the function is defined as "extern void pthread_testcancel (void)".
Where is that C function definition of pthread_testcancel() without any argument matching those of dummythread.h's definition? |
"
The effect of the macro is to replace that call to pthread_testcancel() with nothing. Your problem is that pthread.h gets included through some of the system headers, but the preprocessor doesn't know the difference between a function call (no arguments) and a function prototype ("void" to indicate that the function takes no arguments), so it complains about the prototype. Your solution is to add an argument to the macro, and I was saying this isn't a good solution and will cause a problem when it gets to the code that actually calls the macro -- however I'm wrong, because the preprocessor doesn't know the difference between a macro call with one argument and a macro call with no arguments. I still think it's not a good solution. If there's a need for pthread.h in the standard library, including dummypthread.h first might cause issues, since it makes a few core pthread functions no-ops. My preference in this case would be to either build the broker with the thread calls in place or to change the way the pthread functions are stubbed out, e.g., like this:
|
Thanks @ptjm for your detailed and competent explanation and the time you took for it! |
Thanks for the analysis @ptjm, I'm not sure I agree about your final point though. dummypthread.h is only included in the mosquitto code, so it only affects the mosquitto code being compiled. It doesn't stop the standard library using those functions if they need to. I think there needs to be a separate review of the threading use in the broker, at the very least there should be some help for plugins that might want to use separate threads. At that point this will become moot. |
I cannot compile moquitto 1.6.15 for FritzBox, while I could compile 1.6.8 successfully. Error message is
macro "pthread_testcancel" passed 1 arguments, but takes just 0
uClibc's pthread.h in the version 0.9.32.1 defines
extern void pthread_testcancel (void);
while mosquitto's dummythread.h does#define pthread_testcancel()
Patching moquitto's dummypthread.h resolved the problem
Other binaries on the box are compiled by the vendor and cannot be recompiled since they are closed source. So an upgrade of uClibc is not an option. Could you please add support for those older uClibc versions?
Thanks you!
The text was updated successfully, but these errors were encountered: