1 Reply Latest reply on Jun 25, 2018 2:56 AM by JobinT_31

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

      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; 
      typedef int64_t int64;    
      typedef uint64_t uint64;
      #endif  /* (!CY_PSOC3) */