Skip to content
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

Prototype of subscribe_callback is incorrect #2367

Closed
snej opened this issue Nov 4, 2021 · 1 comment
Closed

Prototype of subscribe_callback is incorrect #2367

snej opened this issue Nov 4, 2021 · 1 comment

Comments

@snej
Copy link

snej commented Nov 4, 2021

The prototype of subscribe_callback in mosquitopp.h doesn't match the function definition in mosquittopp.cpp -- the one in the header has a parameter bool retained that doesn't appear in the impl.

The result is that client code that calls this function will produce a link error, since it's calling a function with a different mangled name than the one implemented. There will also be a warning or error if compiling with strict prototype checking:

/Users/snej/Couchbase/Tools/couchbase-mobile-tools/vendor/mosquitto/lib/cpp/mosquittopp.cpp:156:19: error: no previous prototype for function 'subscribe_callback' [-Werror,-Wmissing-prototypes]
mosqpp_EXPORT int subscribe_callback(
                  ^

It looks as though the parameter should be removed from the header. The implementation just calls through to mosquitto_subscribe_callback, which has no corresponding retained parameter, so there's no point in passing one to the C++ function.

@snej
Copy link
Author

snej commented Nov 4, 2021

Here's a patch:

diff --git a/lib/cpp/mosquittopp.h b/lib/cpp/mosquittopp.h
index be9016d62f102ceee8332d62ef570b53084135d5..f47535a9e96d8687d9ed4f48f43208210b63c6a4 100644
--- a/lib/cpp/mosquittopp.h
+++ b/lib/cpp/mosquittopp.h
@@ -64,7 +64,6 @@ mosqpp_EXPORT int subscribe_callback(
 		void *userdata,
 		const char *topic,
 		int qos=0,
-		bool retained=true,
 		const char *host="localhost",
 		int port=1883,
 		const char *client_id=NULL,

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant