`int32_t` in ESP v5.0 vs v4.4.2

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

`int32_t` in ESP v5.0 vs v4.4.2

Postby mbratch » Thu Dec 22, 2022 5:28 pm

When I was using v4.4.2 ESP-IDF with whatever version of the gcc compiler it installs by default, I was using a `%d` specifier to print `int32_t`. If I used `%ld` it would give me a warning. When I updated to v5.0, which also uses a later version of the C compiler, the opposite occurred: an `int32_t` expected a `%ld` specifier (which I reckon is what I'd really expect) and will warn if `%d` is used.

This isn't a problem, but I'm surprised that this interpretation of `int32_t` changed. I know some compilers on some architectures would consider a 32-bit integer as a long, and some would consider a 64-bit as a long. But obviously my architecture hasn't changed. So the newer version of the compiler seems to consider `uint32_t` as a long on ESP32, whereas the older version did not. Has anyone else seen this? I'm curious as to why it is different.

chegewara
Posts: 2371
Joined: Wed Jun 14, 2017 9:00 pm

Re: `int32_t` in ESP v5.0 vs v4.4.2

Postby chegewara » Fri Dec 23, 2022 9:49 pm


User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: `int32_t` in ESP v5.0 vs v4.4.2

Postby mbratch » Fri Dec 23, 2022 10:24 pm

Thank you! Interesting discussion (I haven't gotten through half the thread yet!). It turns out not to have affected me much (two lines of my code, that's all). The primary answer to my question lies in the statement noted in there:
...we have changed the definition of uint32_t for Xtensa from unsigned int to unsigned long to match the way it is defined in upstream GCC, and also for the other architectures.

Who is online

Users browsing this forum: benrank, Majestic-12 [Bot], MicroController and 112 guests