Skip to content

fix build with gcc 15 #249

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

Merged
merged 1 commit into from
May 14, 2025
Merged

Conversation

ftapajos
Copy link
Contributor

@ftapajos ftapajos commented May 1, 2025

gcc 15 uses c23 as default. paho.mqtt.c is written with c11

gcc 15 uses c23 as default
@fpagliughi
Copy link
Contributor

fpagliughi commented May 2, 2025

c11? I would have guessed c89... with maybe a line or two of c99 thrown in. :-)

I'll get a few more recent versions of gcc set up to test and then get this in. (I seem to still have gcc 12 on most of my machines)

Just curious. Can you cut-and-paste the errors that gcc 15 is giving? It's probably worth trying to get the Paho C lib updated for this. If nothing else, push the standard definition into the CMake files for that lib.

@fpagliughi
Copy link
Contributor

Oh, and thanks for reporting this!

@ftapajos
Copy link
Contributor Author

ftapajos commented May 5, 2025

@fpagliughi , The error is related to the fact that bool is now a C keyword

In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolClient.h:25,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolClient.c:35:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_obj_static.dir/build.make:93: src/CMakeFiles/common_obj_static.dir/MQTTProtocolClient.c.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacketOut.h:23,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacketOut.c:30:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_obj_static.dir/build.make:149: src/CMakeFiles/common_obj_static.dir/MQTTPacketOut.c.o] Error 1
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.c:28:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_obj_static.dir/build.make:135: src/CMakeFiles/common_obj_static.dir/MQTTPacket.c.o] Error 1
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolClient.h:25,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolClient.c:35:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.c:28:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:93: src/CMakeFiles/common_ssl_obj_static.dir/MQTTProtocolClient.c.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:135: src/CMakeFiles/common_ssl_obj_static.dir/MQTTPacket.c.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:125: src/CMakeFiles/common_obj_static.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacketOut.h:23,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacketOut.c:30:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:149: src/CMakeFiles/common_ssl_obj_static.dir/MQTTPacketOut.c.o] Error 1
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/Log.c:27:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolClient.h:25,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPersistence.c:31:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:205: src/CMakeFiles/common_ssl_obj_static.dir/Log.c.o] Error 1
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:219: src/CMakeFiles/common_ssl_obj_static.dir/MQTTPersistence.c.o] Error 1
  In file included from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolOut.h:26,
                   from /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTProtocolOut.c:38:
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: error: 'bool' cannot be defined via 'typedef'
     31 | typedef unsigned int bool;
        |                      ^~~~
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:22: note: 'bool' is a keyword with '-std=c23' onwards
  /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paho-mqtt-sys-0.10.1/paho.mqtt.c/src/MQTTPacket.h:31:1: warning: useless type name in empty declaration
     31 | typedef unsigned int bool;
        | ^~~~~~~
  make[2]: *** [src/CMakeFiles/common_ssl_obj_static.dir/build.make:247: src/CMakeFiles/common_ssl_obj_static.dir/MQTTProtocolOut.c.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:221: src/CMakeFiles/common_ssl_obj_static.dir/all] Error 2
  make: *** [Makefile:156: all] Error 2

  thread 'main' panicked at /home/tapajos/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cmake-0.1.54/src/lib.rs:1119:5:

  command did not execute successfully, got: exit status: 2

@fpagliughi
Copy link
Contributor

Ok. There is already an issue on the Paho C repo about this:
eclipse-paho/paho.mqtt.c#1576

I do want to fix this in the C lib, but even if I put up a PR now, it could be a while before the next C release. So we can get this in to the Rust builder to keep us going.

@otaxhu
Copy link
Contributor

otaxhu commented May 8, 2025

I tried by myself to compile using CFLAGS=-std=c11 and it worked/compiled.

But I guess it's much better to support older compilers.

Please take a look at this PR in the C library, it's 1 month old and hasn't received any comments

eclipse-paho/paho.mqtt.c#1595

@otaxhu
Copy link
Contributor

otaxhu commented May 8, 2025

@fpagliughi I tested compiling with CFLAGS=-std=c89 and it did not compiled.

[ellided]/paho.mqtt.c/src/MQTTProtocolClient.h:60:1: error: C++ style comments are not allowed in ISO C90
     60 | //#define MQTTStrdup(src) MQTTStrncopy(malloc(strlen(src)+1), src, strlen(src)+1)
        | ^
[...more-similars...]

EDIT:
Tested with CFLAGS=-std=c99 and it worked, so c99 or c11 could do it

@fpagliughi
Copy link
Contributor

Yeah, I think the proper solution is what the C library is targeting. At this point, the C library is going with C99, so we can use that.
eclipse-paho/paho.mqtt.c#1576 (comment)

@fpagliughi fpagliughi merged commit 0a60494 into eclipse-paho:master May 14, 2025
5 checks passed
@fpagliughi
Copy link
Contributor

OK. I pushed the C version back to C99 to be keep with the version that the C library is claiming to track, then published a new -sys crate (v0.10.3) which should fix the latest version of this crate currently up on crates.io.

I also sent a PR to the C lib to fix the upstream library:
eclipse-paho/paho.mqtt.c#1597

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants