Uint24_t and uint48_t in MinGW

I am looking for the types uint24_t and uint48_t in GCC and MinGW. I know that they are not standardized, but I have met links to them on the Internet, and I'm trying to find out:

  • What title do I need to include for them.
  • Regardless of whether they are cross-platform (at least on Windows, Linux, and Mac OSX) or just for specific purposes.
  • What are their names. uint24_t, __uint24, __uint24_t?
+6
source share
1 answer

The standard uintXX_t types are provided in stdint.h (C, C ++ 98) or cstdint (C ++ 11).

In 8-bit data, the 24-bit AVR address architecture, GCC provides a built-in 24-bit integer, but it is not portable. See http://gcc.gnu.org/wiki/avr-gcc for more details.

There are no standard 24-bit or 48-bit integer types provided by GCC or MinGW in a platform-independent way, but one simple way to get a portable 24-bit number on almost any platform is to use a bit field:

struct bitfield24 { uint32_t value : 24; }; bitfield24 a; a.value = 0xffffff; a.value += 1; assert(a == 0); 

The same can be done for 48 bits using uint64_t as the base.

+9
source

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


All Articles