Surely the answer to the question is a simple "no" - for all normal CPUs.
And similarly an "int" is same as "long" and same as int32_t.
Are there any exceptions?
I am a mere novice here...
I never use a "long", but I do use "int" for trivia like for loop variables which only run from 0 to 1000
My 32F4 code will never be ported down to a Z80, and I will be long dead before it gets ported to a 64 bit CPU, but if it was, it should still run the same, except any "int" will take up 8 bytes instead of 4.
Check this Wikipedia page:
https://en.wikipedia.org/wiki/C_data_typesC data type
int is at least 16-bits in size. Typically the size of the
int data type is identical to the native data size of the target system. For example, in systems with 16-bit architecture the size of the
int is 16 bits, and in 32-bit architectures
int is 32 bits. In 8-bit systems, the size of the
int will be 16 bits by definition.
C data type
long is at least 32-bits in size.
C data type
int32_t is exactly 32-bits in size by definition.
As you can see, the data sizes of
int,
long and
int32_t will probably be the same only in 32-bit architectures.
As a rule of a thumb it is recommended to use
int in loops and for temporary variables (unless you know better, or the numerical range of
int is not sufficient), as this will typically produce the best performance and best code size. Using
long in the loops and for temporary variables where the numerical range of
int would suffice is just a bad habit, which may lead poor performance and larger code size.