-1
long number = 100;
printf("the sizeof: %d", sizeof(number));

In Visual Studio, I get the result 4. In Xcode, whereas I get the result 8.

Same code, different result. Could you tell me why I get this result?

Mium
  • 303
  • 1
  • 2
  • 12
  • Also https://stackoverflow.com/questions/18901080/why-is-the-sizeofint-sizeoflong?r=SearchResults – matt Mar 18 '19 at 06:00

1 Answers1

1

See here: long is guaranteed by the standard to be "at least 32 bits", and depending on the data model may be bigger.

If you want "exactly 32 bits", try if int32_t is supported.

Amadan
  • 191,408
  • 23
  • 240
  • 301