Languages/C/inttypes

(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
{{private}}
 
 
{{TOC right}}
 
{{TOC right}}
  
Line 40: Line 39:
 
=== HI TECH PIC18 C compiler ===
 
=== HI TECH PIC18 C compiler ===
 
There is no <code>(u)int64_t</code>.
 
There is no <code>(u)int64_t</code>.
 +
 +
[[Category:Languages]] [[Category:C]]

Revision as of 07:17, 12 July 2012

Contents

Integer types in C

The C language defines a lot of integer types (char, short, int, unsigned int,...) but unfortunatly there size depends on the platform (or compiler).

Writing programs in a portable manner requires the use of known size.

C99 integer sizes

Recent compilers provide the <stdint.h> file that defines a lot of integer types, and because this is a standard, new code should no more use the "old" HEVs coding style.

C99 type Old HEVs type size (bits) minimum value (define) minimum value (numeric) maximum value (define) maximum value (numeric)
uint8_t UINT8 8 - 0 UINT8_MAX 255
uint16_t UINT16 16 - 0 UINT16_MAX 65'535
uint32_t UINT32 32 - 0 UINT32_MAX 4'294'967'295
uint64_t UINT64 64 - 0 UINT64_MAX 18'446'744'073'709'551'615
int8_t INT8 8 INT8_MIN -128 UINT8_MAX 127
int16_t INT16 16 INT16_MIN -3'2768 UINT16_MAX 32'767
int32_t INT32 32 INT32_MIN -2'147'483'648 UINT32_MAX 2'147'483'647
int64_t INT64 64 INT64_MIN -9'223'372'036'854'775'807 UINT64_MAX 9'223'372'036'854'775'807

Compiler support & remarks

GCC

gcc fully supports <stdint.h>.

HI TECH PIC18 C compiler

There is no (u)int64_t.

Personal tools
Namespaces
Variants
Actions
Navigation
Browse
Toolbox