Cypress技术论坛
直播中

张晓宁

7年用户 210经验值
私信 关注
[问答]

为什么不使用stdint.h而不是传统的固定大小类型来拥抱C99?

我知道各种柏树开发工具应该是C99兼容。
虽然这是现在一个很老的标准,这是难能可贵的至少渴望这种兼容性。
对C语言的那部分的重要改进之一是C99的& lt介绍;H & gt;文件的头文件定义了固定大小的整数类型编译程序中的独立的方式。
尽管如此,柏树的头文件和源文件继续使用Cypress的固定大小的整数类型而不是<;文件H & gt;。这个标题实际上是包含在& lt;cytypes。H & gt;但不使用Cypress的代码。
为什么不大胆地抓住这个千年,取代那些类型与C标准的?
也就是说,代替UIT32使用Uti32 32 t等。
客户的遗留代码仍然可以通过现有的& lt是兼容的;cytypes。H & gt;头,但没有理由柏自己的代码使用旧的定义。所以目前在& lt定义;cytypes。H & gt;,这个标题可以这样做:
#包括<;文件H & gt;typedef uint8_t uint8;typedef uint16_t uint16;typedef uint32_t UInt32;typedef int8_t智力int16_t int16类型;定义;int32_t Int32;/*符号或取决于编译器的选择* / typedef char char8符号;#如果(!cy_psoc3)typedef int64_t Int64;typedef uint64_t UInt64;# endif / *(!Cyp- SOC3)*/

以上来自于百度翻译


     以下为原文
  I know that the various Cypress development tools are supposed to be C99 compatible.
Though this is by now a very old standard, it's commendable to at least aspire to this compatibility.
One of the important improvements to the C language that was part of C99 was the introduction of the header file that defines fixed-sized integral types in a compiler-independent way.
Despite this, the Cypress header and source files continue to use Cypress' own fixed-size integral types instead of those from . This header is actually included in but not used in Cypress' code.
Why not step boldly into this millennium and replace those typedefs with the C standard ones?
That is: instead of uint32 use uint32_t, etc.
Customers' legacy code can still be compatible through the existing header, but there's no reason for Cypress' own code to use the old definitions. So instead of the current definitions in , this header could just do this:
#include
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
/* Signed or unsigned depending on compiler selection */
typedef char   char8;  
#if(!CY_PSOC3)     
typedef int64_t int64;     
typedef uint64_t uint64;
#endif  /* (!CY_PSOC3) */

回帖(1)

刘慧

2018-9-7 11:43:31
你好,Ned,
谢谢你的建议,我们已经转发给PSoC Creator开发团队看了。
谢谢
Jobin燃气轮机

以上来自于百度翻译


     以下为原文
  Hello Ned,
 
Thank you for your suggestion, we had forwarded this to PSoC Creator development team to have a look at.
 
Thanks
Jobin GT
举报

更多回帖

发帖
×
20
完善资料,
赚取积分