Where are the types 'int' and 'char' defined in the C programming language?

I learn how the C language works. I can find definitions for type types int8_t, intptr_tetc. In <stdlib.h>:

// Represents true-or-false values
typedef _Bool bool;
enum { false, true };

// Explicitly-sized versions of integer types
typedef __signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;

// Pointers and addresses are 32 bits long.
// We use pointer types to represent virtual addresses,
// uintptr_t to represent the numerical values of virtual addresses,
// and physaddr_t to represent physical addresses.
typedef int32_t intptr_t;
typedef uint32_t uintptr_t;
typedef uint32_t physaddr_t;

However, I cannot find a type definition for the type char. So my question is: where are defined intand char?

+4
source share
4 answers

Types charand int, among other things, are not defined in any header file. They are built by type, that is, they are part of the main language. Their definitions are hardcoded in the compiler itself.

, , , C.

int char 6.2.5 (). , char:

3 , char, . char, . - char, , , .

, , .

+5

char ?

- char - , . . int.

?

. .


, char, int , , , .

+8

, "" int8_t, intptr_t .. - .

char, int, long, double .. - . ( ).

<limits.h> ; , :

/* Number of bits in a `char'.  */
#  define CHAR_BIT      8

/* Minimum and maximum values a `signed char' can hold.  */
#  define SCHAR_MIN     (-128)
#  define SCHAR_MAX     127

/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */
#  define UCHAR_MAX     255

/* Minimum and maximum values a `char' can hold.  */
#  ifdef __CHAR_UNSIGNED__
#   define CHAR_MIN     0
#   define CHAR_MAX     UCHAR_MAX
#  else
#   define CHAR_MIN     SCHAR_MIN
#   define CHAR_MAX     SCHAR_MAX
#  endif

/* Minimum and maximum values a `signed short int' can hold.  */
#  define SHRT_MIN      (-32768)
#  define SHRT_MAX      32767

/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */
#  define USHRT_MAX     65535

/* Minimum and maximum values a `signed int' can hold.  */
#  define INT_MIN       (-INT_MAX - 1)
#  define INT_MAX       2147483647

/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */
#  define UINT_MAX      4294967295U

/* Minimum and maximum values a `signed long int' can hold.  */
#  if __WORDSIZE == 64
#   define LONG_MAX     9223372036854775807L
#  else
#   define LONG_MAX     2147483647L
#  endif

, , ; , . <float.h>, - .

char - , , ( , -, , ..). char 8 , . - char - ([0...127]), , "plain" char , signed char unsigned char. .

int , , [-32767...32767]. , .

C 1970- , . 7 9 , 16 18 , .. , . , (2 , 1 , ..). , , .

0

Source: https://habr.com/ru/post/1683539/


All Articles