Int or int32 in for loop? C++

I have this for loop in which I use int32 , so is it ok?

int32 limit = 16;
for (int32 i = 1; i <=  limit;  i++)
	{
		//some code
	}
1 Like

https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/

Portable C++ code

Use of C++'s int and unsigned int types—whose size may vary across platforms, but which is guaranteed to be at least 32 bits in width—is acceptable in code where the integer width is unimportant. Explicitly-sized types must still be used in serialized or replicated formats.

  • uint8 for unsigned bytes (1 byte).
  • int8 for signed bytes (1 byte).
  • uint16 for unsigned “shorts” (2 bytes).
  • int16 for signed “shorts” (2 bytes).
  • uint32 for unsigned ints (4 bytes).
  • int32 for signed ints (4 bytes).
  • uint64 for unsigned “quad words” (8 bytes).
  • int64 for signed “quad words” (8 bytes).
4 Likes

Thank you for reply, it helps me very much :slight_smile:
so int32 represents signed integers with values that range from negative 2,147,483,648 and I must not use it to define types under loops?

It is ok to use in loops.

3 Likes

Thank you very much for correcting me