本文介绍了UINT32_C和uint32_t之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知 uint32_t 中的后缀 t 表示 t 类型,但我想知道 C是什么 UINT32_C 中有什么区别?

解决方案

UINT32_C 是一个宏,它定义类型为 uint_least32_t 的整数常量。例如:

  UINT32_C(123)//可能在uint_least32_t为无符号long 
//的系统上扩展为123UL //如果uint_least32_t是unsigned int,则仅为123U。



因此,在某些罕见的系统上,此常数可能超过32位。



但是,如果您使用的系统中定义了多个8位2的补码类型(大多数现代系统),并且存在 uint32_t ,则这将创建32位常量



它们均在 stdint.h 中定义,自C99以来已成为C标准的一部分。 / p>

As far as I know the suffix t in uint32_t denote type name but I wonder to know what is the C in UINT32_C and what is the differences?

解决方案

UINT32_C is a macro which defines integer constant of type uint_least32_t. For example:

UINT32_C(123) // Might expand to 123UL on system where uint_least32_t is unsigned long
              // or just 123U, if uint_least32_t is unsigned int.

It is thus possible that this constant is more than 32 bits on some rare systems.

But if you are on a system where multiple of 8-bits 2's complement types are defined (most modern systems), and uint32_t exists, then this creates 32-bit constant.

They all are defined in stdint.h, and have been part of the C standard since C99.

这篇关于UINT32_C和uint32_t之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 02:05