Default Int data types

Hi im using PIO for esp32 module development in Arduino framework. I have some code that I did not write that declares variables such as:
unsigned int

What is the defaut for this…is it an 8-bit, 16-bit, etc.?

Based on the answer, is there a way to globally change the default?


ESP32/XTensa32 has an int size of 32-bits / 4 byytes.

You can see that for yourself by inspecting sizeof(int) in the IDE or at runtime, or looking at the INT_MAX / INT_MIN macros from limits.h.

If you wanted your application to use fixed-width integers, it should have been written using stdint.h types instead, such as int32_t, uint16_t, etc.

As far as I know, there are no compiler settings for the XTensa GCC to arbitrarily change the size of the fundmental types (int, short, char, long, etc).

1 Like