Gcc, width of long int on different architectures

In 64-bit architectures long int, according to gcc, at least int64_t. In a 32-bit version, long intno less int32_t. With compilers, Microsoft is longalways int32_t, regardless of 32/64-bit. Is there any way:

  • Make gcc handle long as int64_t, on 32 bit? (for ease of testing)
  • The power of gcc for lengthy processing of int32_t on 64-bit? (to match the MS compiler).
+3
source share
2 answers

Do not do it - use the standard types, such as int32_t, uint32_t, int64_t, uint64_tetc. <stdint.h>, instead of trying to make assumptions about bare types, such as long intor trying to bend the compiler as you wish.

Note. The 64-bit model for any given platform (for example, LP64 for most * nix platforms, Mac OS X, etc.) is predefined, so even if you can convince the compiler to use another 64-bit model, you will probably break any calls system code, libraries, etc.

+11
source

That is why, in general, it is much easier to use a set of typedefs that are defined for each platform. This will really save you a lot of hassle when compiling on random-platform-with-random-compiler-47.4

0

Source: https://habr.com/ru/post/1776180/


All Articles