Why not embrace C99 by using stdint.h instead of the legacy fixed-size types?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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 <stdint.h> 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 <stdint.h>. This header is actually included in <cytypes.h> 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 <cytypes.h> header, but there's no reason for Cypress' own code to use the old definitions. So instead of the current definitions in <cytypes.h>, this header could just do this:

#include <stdint.h>
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 Solution
JobinT_31
Employee
Employee
50 solutions authored 25 solutions authored 10 solutions authored

Hello Ned,

Thank you for your suggestion, we had forwarded this to PSoC Creator development team to have a look at.

Thanks

Jobin GT

View solution in original post

0 Likes
1 Reply
JobinT_31
Employee
Employee
50 solutions authored 25 solutions authored 10 solutions authored

Hello Ned,

Thank you for your suggestion, we had forwarded this to PSoC Creator development team to have a look at.

Thanks

Jobin GT

0 Likes