기본 타입 표준 C/C++

c/c++ 표준에서 타입에 대해 명시한 부분을 잘라서 해석해봤다.

쓸데없는 사족이나 쓰기 귀찮은것들은 그냥 뒀음.


ISO C11 표준

6.2.5 Types
The meaning of a value stored in an object or returned by a function is determined by the type of the expression used to access it.
(An identifier declared to be an object is the simplest such expression; the type is specified in the declaration of the identifier.)
쓸데없는 내용임

Types are partitioned into object types (types that describe objects) and function types (types that describe functions).
: 타입은 객체를 표현하는 타입과 함수를 표현하는 타입으로 나뉩니다.

At various points within a translation unit an object type may be incomplete (lacking sufficient information to determine the size of objects of that type) or complete (having sufficient information).37)

주37) A type may be incomplete or complete throughout an entire translation unit, or it may change states at different points within a translation unit.

An object declared as type _Bool is large enough to store the values 0 and 1.
: _Bool 타입은 0과 1을 저장할 수 있을 만큼의 크기를 가져야합니다.

An object declared as type char is large enough to store anymember of the basic execution character set.
: char 타입은 기본적인 문자 집합의 멤버들을 전부 저장할 수 있을만큼의 크기를 가져야합니다.

If a member of the basic execution character set is stored in a char object, its value is guaranteed to be nonnegative.
: 만약 기본 문자 집합의 멤버가 char 객체에 저장되었을 경우, 그 값은 음수가 아님을 보장합니다.
(0~127이니까)

If any other character is stored in a char object, the resulting value is implementation-defined but shall be within the range of values that can be represented in that type.
: 다른 문자가 char 객체에 저장될 경우, 그 결과값은 구현-정의되지만 그 타입이 표현할 수 있는 값의 범위 내에 있어야 합니다.
(char에 유니코드 넣어도 의미없단말)

There are five standard signed integer types, designated as signed char, short int, int, long int, and long long int.
: 표준의 부호있는 정수형으론 signed char, short int, int, long int, and long long int 다섯가지가 있습니다.

(These and other types may be designated in several additional ways, as described in 6.7.2.)
: 이것들과 다른 타입들은 6.7.2에서 설명한것처럼 여러 추가적인 방법으로 지정할 수 있습니다.

There may also be implementation-defined extended signed integer types.38)
: 이거 말고도 다른 부호있는-정수타입이 더 확장돼서 구현-정의되어있을수도 있습니다.

주38)Implementation-defined keywords shall have the form of an identifier reserved for anyuse as described in 7.1.3.
: 구현-정의된 키워드는 7.1.3에 기술된 바와 같이 다른 키워드를 위해 예비된 식별자의 형태를 가져야 합니다.

The standard and extended signed integer types are collectively called signed integer types.39)

39)Therefore, anystatement in this Standard about signed integer types also applies to the extended signed integer types.

An object declared as type signed char occupies the same amount of storage as a ‘‘plain’’ char object.
: 부호있는 char타입은 그냥 char 타입과 같은 크기를 가집니다.

A ‘‘plain’’ int object has the natural size suggested by the architecture of the execution environment
: 그냥 int 타입은 실행 환경의 구조에 따라 제공되는 자연스러운 크기를 갖습니다.

(large enough to contain anyvalue in the range INT_MIN to INT_MAX as defined in the header <limits.h>).
: 리밋츠 헤더에서 정의된 Int_min부터 Int_max까지 범위의 모든 값을 담을 수 있을 정도로 커야합니다.

......
limits.h

—number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8
가장 작은 객체를 담을 비트의 수는 비트필드가 아닙니다.(바이트여야 함)

—minimum value for an object of type signed char
SCHAR_MIN -127 // −(27 − 1)
부호 있는 char타입의 최소값.

—maximum value for an object of type signed char SCHAR_MAX +127 // 27 − 1
부호있는 char의 최대값

—maximum value for an object of type unsigned char UCHAR_MAX 255 // 28 − 1
부호없는 char의 최대값

—minimum value for an object of type char CHAR_MIN see below
그냥 char의 최소값

—maximum value for an object of type char CHAR_MAX see below
그냥 char의 최대값

— maximum number of bytes in a multibyte character, for any supported locale MB_LEN_MAX 1
어떤 로케일이 지원되든간에, 멀티바이트에서 바이트의 최대 수.

—minimum value for an object of type short int
SHRT_MIN -32767 // −(215 −1)
short int의 최소값

—maximum value for an object of type short int SHRT_MAX +32767 // 215 − 1
short int의 최대값

—maximum value for an object of type unsigned short int USHRT_MAX 65535 // 216 − 1
부호없는 short int의 최대값

—minimum value for an object of type int
INT_MIN -32767 // −(215 −1)
int의 최소값

—maximum value for an object of type int
INT_MAX +32767 // 215 − 1
int의 최대값

—maximum value for an object of type unsigned int UINT_MAX 65535 // 216 − 1
부호없는 int의 최대값

—minimum value for an object of type long int
LONG_MIN -2147483647 // −(231 −1)
long의 최소값

—maximum value for an object of type long int
LONG_MAX +2147483647 // 231 − 1
long의 최대값

—maximum value for an object of type unsigned long int ULONG_MAX 4294967295 // 232 − 1
부호없는 long의 최대값

If the value of an object of type char is treated as a signed integer when used in an expression, the value of CHAR_MIN shall be the same as that of SCHAR_MIN and the value of CHAR_MAX shall be the same as that of SCHAR_MAX.
: char타입의 값이 표현식에서 사용될 때 부호있는 정수로 취급될 경우, char의 최소값은 부호있는 char의 최소값과 같아야 하고, char의 최대값이 부호있는 char의 최대값과 같아야합니다.

Otherwise, the value of CHAR_MIN shall be 0 and the value of CHAR_MAX shall be the same as that of UCHAR_MAX.20)
: 아니면 char의 최소값이 0이여야 하고, char의 최대값은 부호없는 char의 최대값과 같아야합니다.
->말 더럽게 뱅뱅 돌리네요. 요약하면 그냥 char의 부호는 제멋대로라는 뜻. 컴파일러 의존.

The value UCHAR_MAX shall equal 2CHAR_BIT −1.
부호없는 char의 최대값은 2^8 -1와 같아야합니다.

......


For each of the signed integer types, there is a corresponding (but different) unsigned integer type (designated with the keyword unsigned)that uses the same amount of storage (including sign information) and has the same alignment requirements.

The type _Bool and the unsigned integer types that correspond to the standard signed integer types are the standard unsigned integer types.
사족

The unsigned integer types that correspond to the extended signed integer types are the extended unsigned integer types. 
사족

The standard and extended unsigned integer types are collectively called unsigned integer types.40)
사족

주40)Therefore, anystatement in this Standard about unsigned integer types also applies to the extended unsigned integer types.

The standard signed integer types and standard unsigned integer types are collectively called the standard integer types,the extended signed integer types and extended unsigned integer types are collectively called the extended integer types.
사족

For any two integer types with the same signedness and different integer conversion rank (see 6.3.1.1), the range of values of the type with smaller integer conversion rank is a subrange of the values of the other type.
: 부호가 같고 정수 변환 순위가 다른 두 정수 타입(6.3.1.1 참조)의 경우, 정수 변환 순위가 더 작은 유형의 값은 큰 값의 하위 범위가 됩니다.

The range of nonnegative values of a signed integer type is a subrange of the corresponding unsigned integer type, and the representation of the same value in each type is the same.41)
: 부호있는 정수 타입에서 음수가 아닌 값의 범위는 해당하는 부호없는 정수타입의 하위 범위입니다.
각각의 타입에서 같은 값의 표현은 같습니다.
->말을 꼬아놨는데 언사인드 int의 10이나 int의 10이나 같다는 뜻.

주41) The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions.
사족

A computation involving unsigned operands can never overflow, because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting type.
: 부호 없는 값을 대상으로 한 연산은 오버플로를 일으키지 않습니다.
부호없는 정수 타입의 결과값은 그 타입의 최대값(unsigned char의 경우 255)에 1을 더한 값으로 나머지셈을 한 값이 되기 때문이죠.
ex)(unsigned char) 결과값이 257이면 257%(255+1), 1이 됨

There are three real floating types, designated as float, double, and long double.42)
: 부동소수점 타입은 총 세개가 있는데, float, double, long double이 그겁니다.

주42) See ‘‘future language directions’’ (6.11.1).

The set of values of the type float is a subset of the set of values of the
type double;
: float 타입의 값은 double 타입의 서브셋(부분집합)입니다.

the set of values of the type double is a subset of the set of values of the type long double.
: double 타입의 값은 long double의 서브셋입니다.

There are three complex types, designated as float _Complex, double _Complex, and long double _Complex.43) (Complex types are a conditional
feature that implementations need not support; see 6.10.8.3.)
: 복소수 읅ㅅㄴㄹㅈㅇㄴㅎㅎ

The real floating and complex types are collectively called the floating types.
사족

For each floating type there is a corresponding real type,which is always a real floating type.

For real floating types, it is the same type.

Forcomplextypes, it is the type given by deleting the keyword _Complex from the type name.

Each complextype has the same representation and alignment requirements as an array type containing exactly twoelements of the corresponding real type;

the first element is equal to the real part, and the second element to the imaginary part, of the complex number.

The type char, the signed and unsigned integer types, and the floating types are collectively called the basic types.
: char이나 정수타입들, 부동소수점타입들을 기본 타입이라 통칭합니다.

The basic types are complete object types.
: 그리고 기본타입들은 완전한 객체 타입입니다.

Even if the implementation defines two or more basic types to have the same representation, they are nevertheless different types.44)
: 구현과 정의가 둘 이상의 기본 타입을 동일한 표현으로 정의하더라도 그건 다른 타입입니다.
->예를 들어 int와 long은 대체로 같은 크기의 정수형으로 정의되곤 하지만, 완전히 다른 타입으로 인식된다. 이거말하는것같다...

주44)An implementation may define newkeywords that provide alternative ways to designate a basic (or anyother) type;
this does not violate the requirement that all basic types be different. Implementation-defined keywords shall have the form of an identifier reserved for anyuse as described in 7.1.3.

The three types char, signed char, and unsigned char are collectively called the character types.
사족

The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.45)
: 구현은 char에 부호가 있든 없든간에 동일한 범위, 표현 및 동작을 가지도록 정의해야 합니다.

An enumeration comprises a set of named integer constant values.
: 열거는 정수 상수값들에 이름을 붙인 집합으로 구성됩니다.

Each distinct enumeration constitutes a different enumerated type.
: 각각의 열거는 다른 열거형식으로 취급됩니다.

The type char,the signed and unsigned integer types, and the enumerated types are collectively called integer types.
: 사족

The integer and real floating types are collectively called real types.
: 사족

Integer and floating types are collectively called arithmetic types.
: 사족

Each arithmetic type belongs to one type domain: the real type domain comprises the real types, the complex type domain comprises the complex types.

The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.
: void 타입은 비어있는 값을 가집니다. 완성될 수 없는 미완성의 객체죠.

Any number of derived types can be constructed from the object and function types, as follows:
: 다음과 같이 객체나 함수 타입으로부터 파생된 타입을 구성할 수 있습니다.

— An array type describes a contiguously allocated nonempty set of objects with a particular member object type, called the element type.
: 배열 타입은 인접 할당된, 비어있지 않은 객체들위 집합을 뜻합니다.
배열 내부에 있는건 요소 타입이라고 하죠.

The element type shall be complete whenever the array type is specified.
: 요소 타입은 배열 타입이 지정한 것에 따라 완성되어야 합니다.(타입 고정)

Array types are characterized by their element type and by the number of elements in the array.
: 배열 타입은 그 배열의 요소 타입과 요소들의 숫자를 정합니다.

An array type is said to be derived from its element type, and if its element type is T,the array type is sometimes called ‘‘array of T’’.
사족

The construction of an array type from an element type is called ‘‘array type derivation’’.

— A structure type describes a sequentially allocated nonempty set of member objects (and, in certain circumstances, an incomplete array), each of which has an optionally specified name and possibly distinct type.

— A union type describes an overlapping nonempty set of member objects, each of which has an optionally specified name and possibly distinct type.

— A function type describes a function with specified return type.

A function type is characterized by its return type and the number and types of its parameters.
: 함수 타입은 그것의 반환타입과  파라미터의 숫자와 타입으로 특정됩니다.

A function type is said to be derived from its return type, and if its return type is T, the function type is sometimes called ‘‘function returning T’’.

The construction of a function type from a return type is called ‘‘function type derivation’’.

— A pointer type may be derived from a function type or an object type, called the referenced type.
: 포인터 타입은 함수 타입이나 객체 타입으로부터 파생되는데, 참조 타입이라고 부릅니다.

A pointer type describes an object whose value provides a reference to an entity of the referenced type.
: 포인터 타입은 값이 해당하는 참조 타입의 값에 참조를 제공하는겁니다.

A pointer type derived from the referenced type T is sometimes called ‘‘pointer to T’’.

The construction of a pointer type from a referenced type is called ‘‘pointer type derivation’’.

A pointer type is a complete object type.
: 포인터 타입은 완전 객체 타입입니다.

— An atomic type describes the type designated by the construct _Atomic ( type- name ).

(Atomic types are a conditional feature that implementations need not support; see 6.10.8.3.)

These methods of constructing derived types can be applied recursively.

Arithmetic types and pointer types are collectively called scalar types.

Array and structure types are collectively called aggregate types.46)

주46)Note that aggregate type does not include union type because an object with union type can only contain one member at a time.

An array type of unknown size is an incomplete type.

It is completed, for an identifier of that type, by specifying the size in a later declaration (with internal or external linkage).

A structure or union type of unknown content (as described in 6.7.2.3) is an incomplete type.

It is completed, for all declarations of that type, by declaring the same structure or union tag with its defining content later in the same scope.

A type has known constant size if the type is not incomplete and is not a variable length array type.

Array, function, and pointer types are collectively called derived declarator types.

A declarator type derivation from a type T is the construction of a deriveddeclarator type from T by the application of an array-type, a function-type, or a pointer-type derivation to
T.

A type is characterized by its type category, which is either the outermost derivation of a derivedtype (as noted above inthe construction of derivedtypes), or the type itself if the type consists of no derived types.

Any type so far mentioned is an unqualified type.

Each unqualified type has several qualified versions of its type,47) corresponding to the combinations of one, two, or all three of the const, volatile, and restrict qualifiers.

  1. See 6.7.3 regarding qualified array and function types.

The qualified or unqualified versions of a type are distinct types that belong to the same type category and have the same representation and alignment requirements.48)

Aderivedtype is not qualified by the
qualifiers (if any) of the type from which it is derived.

Further, there is the _Atomic qualifier.

The presence of the _Atomic qualifier designates an atomic type.

The size, representation, and alignment of an atomic type need not be the same as those of the corresponding unqualified type.

Therefore, this Standard explicitly uses the phrase ‘‘atomic, qualified or unqualified type’’ whenever the atomic version of a type is permitted along with the other qualified versions of a type.

The phrase ‘‘qualified or unqualified type’’, without specific mention of atomic, does not include the atomic types.

A pointer to void shall have the same representation and alignment requirements as a pointer to a character type.48)

  1. The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions.

Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements.

All pointers to structure types shall have the same representation and alignment requirements as each other.

All pointers to union types shall have the same representation and alignment requirements as each other.

Pointers to other types need not have the same representation or alignment requirements.

EXAMPLE 1The type designated as ‘‘float *’’ has type ‘‘pointer to float’’.

Its type category is pointer,not a floating type.

The const-qualified version of this type is designated as ‘‘float * const’’ whereas the type designated as ‘‘const float *’’ isnot a qualified type — its type is ‘‘pointer to const-
qualified float’’ and is a pointer to a qualified type.


......


ISO c++ 표준(2017)

Fundamental types [basic.fundamental]

Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set.
: char 타입은 모든 기본 문자들을 저장할수 있을만큼 큰 용량을 가지고 있어야합니다.

If a character from this set is stored in a character object, the integral value of that character object is equal to the value of the single character literal form of that character.
: 문자 타입에 값이 저장될 경우, 그 문자 객체 내부의 정수값은 리터럴 문자의 값과 같습니다.

It is implementation-defined whether a char object can hold negative values.
: char 객체가 음수를 가질 수 있는지 여부는 구현에 따라 다릅니다.
(컴파일러에 따라 sign도, unsigned도 될수 있다는 뜻)

Characters can be explicitly declared unsigned or signed.
: 하지만 unsigned나 signed를 통해 그 여부를 명시할 수 있습니다.

Plain char, signed char, and unsigned char are three distinct types, collectively called narrow character types.
: 어쨌든 그냥 char나 unsigned나 signed나 char형인건 마찬가집니다.

A char, a signed char, and an unsigned char occupy the same amount of storage and have the same alignment requirements (6.11);
: 그리고 저 셋은 용량 먹는게 같습니다.

that is, they have the same object representation.
: 그리고 같은 표현법을 가져요

For narrow character types, all bits of the object representation participate in the value representation.

[Note: A bit-field of narrow character type whose length is larger than the number of bits in the object representation of that type has padding bits; see 12.2.4. —end note ]

For unsigned narrow character type, each possible bit pattern of the value representation represents a distinct number.

These requirements do not hold for other types.

In any particular implementation, a plain char object can take on either the same values as a signed char or an unsigned char;

which one is implementation-defined.

For each value i of type unsigned char in the range 0 to 255 inclusive, there exists a value j of type char such that the result of an integral conversion (7.8) from i to char is j, and the result of an integral conversion from j to unsigned char is i.

There are five standard signed integer types : “signed char”, “short int”, “int”, “long int”, and “long long int”.
: 정수타입에는 요로코롬 5가지가 있어요

In this list, each type provides at least as much storage as those preceding it in the list.
: 이 목록에서 각 유형은 목록의 앞에 있는 것과 최소한 같은 양의 저장소를 제공합니다.
-> char <= short <= int <= long <= long long이라는 뜻

There may also be implementation-defined extended signed integer types.

The standard and extended signed integer types are collectively called signed integer types.
사족

Plain ints have the natural size suggested by the architecture of the execution environment;
: int 타입들은 컴파일러나 실행환경에 따라 다 달라요.

주47) int must also be large enough to contain any value in the range [INT_MIN, INT_MAX], as defined in the header .
int는 헤더에서 정의된 [INT_MIN, INT_MAX] 범위의 값을 담을수 있을만큼 커야합니다.

the other signed integer types are provided to meet special needs.

For each of the standard signed integer types, there exists a corresponding (but different) standard un- signed integer type: “unsigned char”, “unsigned short int”, “unsigned int”, “unsigned long int”, and “unsigned long long int”, each of which occupies the same amount of storage and has the same alignment requirements (6.11) as the corresponding signed integer type;
: 표준의 부호있는 정수형들과 같은 크기를 가지지만, 이와는 달리 부호가 없는 타입들이 있습니다.
unsigned char, unsigned short int, unsigned int, unsigned long int, unsigned long long int 같은것들 말이죠.

주48) See 10.1.7.2 regarding the correspondence between types and the sequences of type-specifiers that designate them.

that is, each signed integer type has the same object representation as its corresponding unsigned integer type.

Likewise, for each of the extended

signed integer types there exists a corresponding extended unsigned integer type with the same amount of storage and alignment requirements.

The standard and extended unsigned integer types are collectively called unsigned integer types.

The range of non-negative values of a signed integer type is a subrange of the corresponding unsigned integer type, the representation of the same value in each of the two types is the same, and the value representation of each corresponding signed/unsigned type shall be the same.

The standard signed integer types and standard unsigned integer types are collectively called the standard integer types, and the extended signed integer types and extended unsigned integer types are collectively called the extended integer types.

The signed and unsigned integer types shall satisfy the constraints given in the C
standard, section 5.2.4.2.1.


4 Unsigned integers shall obey the laws of arithmetic modulo 2n where n is the number of bits in the value representation of that particular size of integer.

주49) This implies that unsigned arithmetic does not overflow because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting unsigned integer type.

Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largest extended character set specified among the supported locales (25.3.1).
wchar_t는 지원되는 로케일 중 가장 큰 범위의 모든 문자 집합들을 표현할 수 있어야 합니다.

Type wchar_t shall have the same size, signedness, and alignment requirements (6.11) as one of the other integral types, called its underlying type.
: wchar_t 타입은 다른 인터그럴 타입 중 하나와 같은 크기, 서명 및 정렬 요구 사항(6.11)이 동일해야 합니다.

Types char16_t and char32_t denote distinct types with the same size, signedness, and alignment as uint_least16_t and uint_least32_t, respectively, in , called the underlying types.

Values of type bool are either true or false.
: bool 타입은 true나 false 값입니다.

주50) Using a bool value in ways described by this International Standard as “undefined”, such as by examining the value of an uninitialized automatic object, might cause it to behave as if it is neither true nor false.

[Note: There are no signed, unsigned, short, or long bool types or values. —end note ] Values of type bool participate in integral promotions (7.6).

Types bool, char, char16_t, char32_t, wchar_t, and the signed and unsigned integer types are collectively called integral types.
: bool, 문자 타입들, 부호 있거나 없거나한 정수 타입들은 인터그럴 타입이라 부릅니다.

주51) Therefore, enumerations (10.2) are not integral; however, enumerations can be promoted to integral types as specified in 7.6.

A synonym for integral type is integer type.

The representations of integral types shall define values by use of a pure binary numeration system.

주52) A positional representation for integers that uses the binary digits 0 and 1, in which the values represented by successive bits are additive, begin with 1, and are multiplied by successive integral power of 2, except perhaps for the bit with the highest position. (Adapted from the American National Dictionary for Information Processing Systems.)

[ Example: This International Standard permits two’s complement, ones’ complement and signed magnitude representations for integral types. —end example ]

8 There are three floating-point types: float, double, and long double.

The type double provides at least as much precision as float, and the type long double provides at least as much precision as double.

The set of values of the type float is a subset of the set of values of the type double;

the set of values of the type double is a subset of the set of values of the type long double.

The value representation of floating-point types is implementation-defined.

[Note: This International Standard imposes no requirements on the accuracy of floating-point operations; see also 21.3. — end note ]

Integral and floating types are collectively called arithmetic types.

Specializations of the standard library template std::numeric_limits (21.3) shall specify the maximum and minimum values of each arithmetic type for an implementation.

A type cv void is an incomplete type that cannot be completed;

such a type has an empty set of values.

It is used as the return type for functions that do not return a value.

Any expression can be explicitly converted to type cv void (8.4).

An expression of type cv void shall be used only as an expression statement (9.2), as an operand of a comma expression (8.19), as a second or third operand of ?: (8.16), as the operand of typeid, noexcept, or decltype, as the expression in a return statement (9.6.3) for a function with the return type cv void, or as the operand of an explicit conversion to type cv void.

A value of type std::nullptr_t is a null pointer constant (7.11).
nullptr_t 타입의 값은 널 포인터 상수입니다.

Such values participate in the pointer and the pointer to member conversions (7.11, 7.12).

sizeof(std::nullptr_t) shall be equal to sizeof(void*).
: nullptr의 사이즈는 void*포인터의 사이즈와 같습니다.

11 [Note: Even if the implementation defines two or more basic types to have the same value representation, they are nevertheless different types. —end note ]


힘들다... 귀찮다..

나중에 생각나면 수정할 것 같다...