Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] log__printf

Hi Roger,
Thanks for the reply.  Well, yes, I've noticed that those functions are on different modules, but there are some cases where some of the headers containing the function prototype gets included when compiling the same file (causing the build issue).
In particular, when building the db_dump (under subdir apps/db_dumps):
- Makefile compiles also lib/send_disconnect.c
- lib/send_disconnect.c includes:
    - src/mosquitto_broker_internal.h (when WITH_BROKER is defined) that defines log__printf (to be used by the broker)
    - lib/logging_mosq.h that defines log__printf again
causing compilation issues.
The worst part is that db_dump is not linked with neither libmosquitto nor the object from the broker that contains log__printf, and it ends up re-defining a dummy stub for all those missing functions.
(on a different note, the Makefile for db_dump should probably use APP_CPPFLAGS, APP_CFLAGS, and APP_LDFLAGS from config.mk instead of redefining its own)

Anyway, a simple fix to the header issue is to simply put a guard around including "logging_mosq.h" in src/send_disconnect.c if WITH_BROKER is defined:
...
#ifndef WITH_BROKER
#include "logging_mosq.h"
#endif
...

I can submit a PR with this fix. Let me know.
Regards,
Fabrizio




On Sat, Mar 20, 2021 at 3:45 PM Roger Light <roger@xxxxxxxxxx> wrote:
Hi Fabrizio,

Thank you, you're quite right that there was an int/unsigned int mismatch. I've fixed it now, but it would have never been a real issue happily.

For your other question, the three files you mention are for three separate parts of the project so they will never be linked together.

Regards,

Roger

On Sat, 20 Mar 2021, 13:30 Fabrizio Bertocci, <fabriziobertocci@xxxxxxxxx> wrote:
Hi,
I am trying to rebuild Mosquitto with the Cosmopolitan cross-platform library, and I've noticed that the log__printf is defined in multiple places:
- apps/db_dump/stubs.c
- lib/logging__mosq.c
- src/logging.c

The function signatures are similar but not exactly the same. On a normal build those differences are ignored by the compiler, but in my case they are not, and compilation fails (Linux gcc 9.3.0)

For example when building apps/db_dump, it builds lib/send_disconnect.c that includes first `src/mosquitto_broker_internal.h`, then `lib/logging_mosq.h` and both headers define log__printf, causing compilation problems.
(those problems apparently are ignored when doing a normal build, but they are treated as errors in my build system).
Also, the linker is going to have 3 versions to choose from (although there are rules to let the linker decide which one to pick, is not the most desirable situation).

Build system aside, there should not be 3 global functions with the same name, especially when there are apps (like db_dump) that use pieces from the libs and the broker.

Unfortunately I'm new to the internals of Mosquitto and I am not the right person to decide what's the best thing to do here.

Any advice?
Regards,
Fabrizio

 
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mosquitto-dev
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mosquitto-dev

Back to the top