This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new e8a5c25a5 encoding/tinycbor: Fix compilation with latest GCC
e8a5c25a5 is described below

commit e8a5c25a56eb2d3cc11c2fce7d516be19a3b06a3
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Jun 11 10:18:01 2025 +0200

    encoding/tinycbor: Fix compilation with latest GCC
    
    Those were added in C23.
    
    In file included from repos/apache-mynewt-core/encoding/tinycbor/
        src/cborencoder_close_container_checked.c:33:
    repos/apache-mynewt-core/encoding/tinycbor/include/tinycbor/
        compilersupport_p.h:160:11: error: ‘unreachable’ redefined [-Werror]
      160 | #  define unreachable() __builtin_unreachable()
          |           ^~~~~~~~~~~
    In file included from repos/apache-mynewt-core/encoding/tinycbor/
        include/tinycbor/cbor.h:30,
                     from repos/apache-mynewt-core/encoding/tinycbor/
        src/cborencoder_close_container_checked.c:31:
    /usr/lib/gcc/x86_64-redhat-linux/15/include/stddef.h:468:9: note: this is
         the location of the previous definition
      468 | #define unreachable() (__builtin_unreachable ())
          |         ^~~~~~~~~~~
    cc1: all warnings being treated as errors
---
 encoding/tinycbor/include/tinycbor/compilersupport_p.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/encoding/tinycbor/include/tinycbor/compilersupport_p.h 
b/encoding/tinycbor/include/tinycbor/compilersupport_p.h
index 5545a93d4..ea04da872 100644
--- a/encoding/tinycbor/include/tinycbor/compilersupport_p.h
+++ b/encoding/tinycbor/include/tinycbor/compilersupport_p.h
@@ -155,9 +155,15 @@ extern "C" {
 #endif
 
 #ifdef __GNUC__
+#ifndef likely
 #  define likely(x)     __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
 #  define unlikely(x)   __builtin_expect(!!(x), 0)
+#endif
+#ifndef unreachable
 #  define unreachable() __builtin_unreachable()
+#endif
 #elif defined(_MSC_VER)
 #  define likely(x)     (x)
 #  define unlikely(x)   (x)

Reply via email to