Peter Nilsson said:
42Bastian Schick wrote: [-snip-]
C99 introduced the intN_t types to cater for programs which
do rely on precise width twos complement integer types,
however programs which make use of them are not strictly
conforming.
Why not conforming? Then why does the std. defines these?
-Neo
An example is the TMS320C5402 you are using, or the TMS320F2812 that
is one of the processors I am working with these days. They can't
provide an exact width int8_t or uint8_t type, because the processor
does not provide types with exactly that many bits.
But it can support all of the least n bits types, and fastest n bits
types.
Here is a <stdint.h> header that I wrote for use with the TI 2812 and
Code Composer Studio, it will probably work with your 5402. Try
copying it into the compiler include directory, where headers like
<stdio.h>, <string.h>, and so on, are.
And as another poster suggested, do a Google search for the N869 draft
of the C standard and read up on the integer types and this header.
Copy the text between the lines into an editor and save as stdint.h.
===================================================
/*************************************************************************************/
/** \file stdint.h
* type definitions and macros for the subset of C99's stdint.h types
* that Code Composer Studio for the TMS320C2812 DSP supports
*
* \date 15-Aug-2003
*
* \author Jack Klein
*
* \b Notes: \n
* Note: not all C99 integer types are supported on this
* platform, in particular, no 8 bit types at all, and no 64
* bit types
*
*************************************************************************************/
#ifndef H_STDINT
#define H_STDINT
/* 7.18.1.1 */
/* exact-width signed integer types */
typedef signed int int16_t;
typedef signed long int32_t;
/* exact-width unsigned integer types */
typedef unsigned int uint16_t;
typedef unsigned long uint32_t;
/* 7.18.1.2 */
/* smallest type of at least n bits */
/* minimum-width signed integer types */
typedef signed int int_least8_t;
typedef signed int int_least16_t;
typedef signed long int_least32_t;
/* minimum-width unsigned integer types */
typedef unsigned int uint_least8_t;
typedef unsigned int uint_least16_t;
typedef unsigned long uint_least32_t;
/* 7.18.1.3 */
/* fastest minimum-width signed integer types */
typedef signed int int_fast8_t;
typedef signed int int_fast16_t;
typedef signed long int_fast32_t;
/* fastest minimum-width unsigned integer types */
typedef unsigned int uint_fast8_t;
typedef unsigned int uint_fast16_t;
typedef unsigned long uint_fast32_t;
/* 7.18.1.4 integer types capable of holding object pointers */
typedef signed long intptr_t;
typedef unsigned long uintptr_t;
/* 7.18.1.5 greatest-width integer types */
typedef signed long intmax_t;
typedef unsigned long uintmax_t;
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
/* 7.18.2.1 */
/* maximum values of exact-width signed integer types */
#define INT16_MAX 32767
#define INT32_MAX 2147483647L
/* minimum values of exact-width signed integer types */
#define INT16_MIN (-INT16_MAX-1)
#define INT32_MIN (-INT32_MAX-1) /* -2147483648 is unsigned
*/
/* maximum values of exact-width unsigned integer types */
#define UINT16_MAX 65535U
#define UINT32_MAX 4294967295UL
/* 7.18.2.2 */
/* maximum values of minimum-width signed integer types */
#define INT_LEAST8_MAX 32767
#define INT_LEAST16_MAX 32767
#define INT_LEAST32_MAX 2147483647L
/* minimum values of minimum-width signed integer types */
#define INT_LEAST8_MIN (-INT_LEAST8_MAX-1)
#define INT_LEAST16_MIN (-INT_LEAST16_MAX-1)
#define INT_LEAST32_MIN (-INT_LEAST32_MAX-1)
/* maximum values of minimum-width unsigned integer types */
#define UINT_LEAST8_MAX 65535U
#define UINT_LEAST16_MAX 65535U
#define UINT_LEAST32_MAX 4294967295UL
/* 7.18.2.3 */
/* maximum values of fastest minimum-width signed integer types */
#define INT_FAST8_MAX 32767
#define INT_FAST16_MAX 32767
#define INT_FAST32_MAX 2147483647L
/* minimum values of fastest minimum-width signed integer types */
#define INT_FAST8_MIN (-INT_FAST8_MAX-1)
#define INT_FAST16_MIN (-INT_FAST16_MAX-1)
#define INT_FAST32_MIN (-INT_FAST32_MAX-1)
/* maximum values of fastest minimum-width unsigned integer types
*/
#define UINT_FAST8_MAX 65535U
#define UINT_FAST16_MAX 65535U
#define UINT_FAST32_MAX 4294967295UL
/* 7.18.2.4 */
/* maximum value of pointer-holding signed integer type */
#define INTPTR_MAX 2147483647L
/* minimum value of pointer-holding signed integer type */
#define INTPTR_MIN (-INTPTR_MAX-1)
/* maximum value of pointer-holding unsigned integer type */
#define UINTPTR_MAX 4294967295UL
/* 7.18.2.5 */
/* maximum value of greatest-width signed integer type */
#define INTMAX_MAX 2147483647L
/* minimum value of greatest-width signed integer type */
#define INTMAX_MIN (-INTMAX_MAX-1)
/* maximum value of greatest-width unsigned integer type */
#define UINTMAX_MAX 4294967295UL
/* 7.18.3 */
/* limits of ptrdiff_t */
#define PTRDIFF_MAX 2147483647L
#define PTRDIFF_MIN (-PTRDIFF_MAX-1)
/* limits of sig_atomic_t */
#define SIG_ATOMIC_MAX 2147483647L
#define SIG_ATOMIC_MIN (-SIG_ATOMIC_MAX-1)
#endif /* __STDC_LIMIT_MACROS */
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
/* 7.18.4.1 macros for minimum-width integer constants */
#define INT16_C(x) (x)
#define INT32_C(x) (x ## l)
#define UINT16_C(x) (x ## u)
#define UINT32_C(x) (x ## ul)
/* 7.18.4.2 macros for greatest-width integer constants */
#define INTMAX_C(x) (x ## l)
#define UINTMAX_C(x) (x ## ul)
#endif /* __STDC_CONSTANT_MACROS */
#endif /* __stdint_h */
/* end of stdint.h */
===================================================