__int8, __int16, __int32, __int64

반응형

Microsoft Specific

Microsoft C/C++ features support for sized integer types. You can declare 8-, 16-, 32-, or 64-bit integer variables by using the __intn type specifier, where n is 8, 16, 32, or 64.

The following example declares one variable for each of these types of sized integers:

__int8 nSmall;      // Declares 8-bit integer
__int16 nMedium;    // Declares 16-bit integer
__int32 nLarge;     // Declares 32-bit integer
__int64 nHuge;      // Declares 64-bit integer

The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms. The __int8 data type is synonymous with type char, __int16 is synonymous with type short, and __int32 is synonymous with type int. The __int64 type has no ANSI equivalent.

Example

The following sample shows that an __intxx parameter will be promoted to int:

// sized_int_types.cpp

#include <stdio.h>

void func(int i) {
    printf_s("%s\n", __FUNCTION__);
}

int main()
{
    __int8 i8 = 100;
    func(i8);   // no void func(__int8 i8) function
                // __int8 will be promoted to int
}

Output

func

'Study > C++' 카테고리의 다른 글

FileChecker  (0) 2010.06.09
STL의 std::string::find_last_of 사용 시 주의 사항  (0) 2010.06.04
volatile  (0) 2010.05.29
mec++에 있는 auto_ptr  (0) 2010.05.28
none MFC에서 memory leak난 부분 찾기  (0) 2010.05.28
TAGS.

Comments