Package: gcc-arm-none-eabi
Version: 15:13.2.rel1-2
Severity: normal

After upgrading to Debian trixie (currently "testing") and thus GCC
13.2.1, inttypes.h doesn't define the 64-bit format specifiers such as
PRIi64 anymore, as demonstrated and explained by the following program:

// $ arm-none-eabi-gcc --version
// arm-none-eabi-gcc (15:13.2.rel1-2) 13.2.1 20231009
//
// $ arm-none-eabi-gcc -c test.c
// test.c: In function 'main':
// test.c:21:31: error: expected ')' before 'PRIi64'
//    21 |         printf("the answer: %" PRIi64 "\n", i);
//       |               ~               ^~~~~~~
//       |                               )
// test.c:18:1: note: 'PRIi64' is defined in header '<inttypes.h>'; did you 
forget to '#include <inttypes.h>'?
//    17 | #include <inttypes.h>
//   +++ |+#include <inttypes.h>
//    18 |

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main(void) {
        int64_t i = 42;
        printf("the answer: %" PRIi64 "\n", i);
        return 0;
}

//
// /usr/include/newlib/machine/_default_types.h correctly defines 
___int64_t_defined,
// (indentation for emphasis mine, in all code excerpts):
//
// #ifdef __INT64_TYPE__
//  typedef __INT64_TYPE__ __int64_t;
//  #ifdef __UINT64_TYPE__
//   typedef __UINT64_TYPE__ __uint64_t;
//  #else
//   typedef unsigned __INT64_TYPE__ __uint64_t;
//  #endif
//  #define ___int64_t_defined 1
// #elif __EXP(LONG_MAX) > 0x7fffffff
//  typedef signed long __int64_t;
//  typedef unsigned long __uint64_t;
//  #define ___int64_t_defined 1
//  ...
//
//
// Next, __int64_t_defined would be set in /usr/include/newlib/sys/_stdint.h:
//
// #ifdef ___int64_t_defined
//  #ifndef _INT64_T_DECLARED
//   typedef __int64_t int64_t ;
//   #define _INT64_T_DECLARED
//  #endif
//  #ifndef _UINT64_T_DECLARED
//   typedef __uint64_t uint64_t ;
//   #define _UINT64_T_DECLARED
//  #endif
//  #define __int64_t_defined 1
// #endif /* ___int64_t_defined */
//
//
// sys/_stdint.h would be included via <stdint.h>, but that doesn't happen
// because GCC picks the wrong stdint.h, from 
/usr/lib/gcc/arm-none-eabi/13.2.1/include/stdint.h.
//
// Finally, PRIi64 and similar macros are not defined in
// /usr/include/newlib/inttypes.h, because __int64_t_defined wasn't defined:
//
// #if __int64_t_defined
//  #define PRId64          __PRI64(d)
//  #define PRIi64          __PRI64(i)
//  #define PRIo64          __PRI64(o)
//  #define PRIu64          __PRI64(u)
//  #define PRIx64          __PRI64(x)
//  #define PRIX64          __PRI64(X)
//
//  #define SCNd64          __SCN64(d)
//  #define SCNi64          __SCN64(i)
//  #define SCNo64          __SCN64(o)
//  #define SCNu64          __SCN64(u)
//  #define SCNx64          __SCN64(x)
// #endif
//
//
// As a workaround, #include <sys/_stdint.h> before #include <inttypes.h> fixes 
the issue.


-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.6.15-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages gcc-arm-none-eabi depends on:
ii  binutils-arm-none-eabi  2.41.90.20240115-1+23
ii  libc6                   2.37-15
ii  libgcc-s1               14-20240201-3
ii  libgmp10                2:6.3.0+dfsg-2+b1
ii  libisl23                0.26-3+b2
ii  libmpc3                 1.3.1-1+b2
ii  libmpfr6                4.2.1-1+b1
ii  libstdc++6              14-20240201-3
ii  zlib1g                  1:1.3.dfsg-3+b1

Versions of packages gcc-arm-none-eabi recommends:
ii  libnewlib-arm-none-eabi  4.4.0.20231231-2

gcc-arm-none-eabi suggests no packages.

-- no debconf information

Reply via email to