Wednesday, 21 November 2012

Size of data types in c.

I wrote a program to clear the concepts about size of data types in C.There are four types of data types in C-
  1. int
  2. char
  3. float
  4. double  
There are many data type modifiers in C like signed,unsigned ,long and short.Some modifiers are compatible with some specific data types and not compatible with some datatypes.These issues in brief are following:-



1)Signed and unsigned modifiers are only used with char and int.
2)Short used with only int.
3)Long used with int,float,double.
4)By default ints & chars are signed.
5)long long is only compatible with int

Size of datatype depends upon the compiler options.It also varies when data types modifiers are used .Signed & unsigned modifiers are used in only ints & chars.By default ints & chars are signed.Here is output of my program which explains diffrent sizes of different data type with various type of modifiers on a 64 bit O.S & 64 bit microprocessor with two type of vs option win 32 and x64.Since x64 vs executable does not run on 32 bit opearting syastem.So we have to total three type of list.There is various new data types in the list which are windows data types like Word,Dword etc.We are displaying their name,size,typeid.name,typeid,typeidraw_name for each of them

Windows Windows Windows Windows
64-bit up
64-bit os
32-bit vs option
64-bit up
64-bit os
64-bit vs option
64-bit up
32-bit os
32-bit vs option
64-bit up
32-bit os
64-bit vs option
Datatype Modifier(Signed/unsigned) Modifier(Long/Short) Basic Data Type size of data type   typeid(datatype).name        TypeId(datatype) typeid(datatype)raw_name size of data type typeid(datatype).name        TypeId(datatype) typeid(datatype)raw_name size of data type typeid(datatype).name        TypeId(datatype) typeid(datatype)raw_name
 int Default Default int 4 int 13674340     .H 4 int 1636288 .H 4 int 14106892 .H
 long Default(signed) long Default(int) 4 long 13674340    .J 4 long 1636288 .J 4 long 14106892 .J
 short Default(signed) short Default(int) 2 short 13674340       .F 2 short 1636288 .F 2 short 14106892 .F
 signed signed Default Default(int) 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
 unsigned unsigned Default Default(int) 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I not applicable
 signed short signed short Default(int) 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
 unsigned short unsigned short Default(int) 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
 signed long signed long Default(int) 4 long 13674340 .J 4 long 1636288 .J 4 long 14106892 .J
 unsigned long unsigned long Default(int) 4 unsigned long 13674340 .K 4 unsigned long 1636288 .K 4 unsigned long 14106892 .K
 long signed int signed long int 4 long 13674340 .J 4 long 1636288 .J 4 long 14106892 .J
 long unsigned int unsigned long int 4 unsigned long 13674340 .K 4 unsigned long 1636288 .K 4 unsigned long 14106892 .K
 short signed int  signed short int 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
 short unsigned int unsigned short int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
Short int Default(signed) short int 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
long int Default(signed) long int 4 long 13674340 .J 4 long 1636288 .j 4 long 14106892 .j
long long  Default(signed) long long int 8 _int64 13674340 ._J 8 _int64 1636288 ._j 8 _int64 14106892 ._j
long long int Default(signed) long long int 8 _int64 13674340 ._J 8 _int64 1636288 ._j 8 _int64 14106892 ._j
long long signed int Default(signed) long long int 8 _int64 13674340 ._J 8 _int64 1636288 ._j 8 _int64 14106892 ._j
long long unsigned int Default(signed) long long int 8 unsigned _int64 13674340 ._K 8 unsigned _int64 1636288 ._K 8 unsigned _int64 14106892 ._K
long long signed Default(signed) long long int 8 _int64 13674340 ._J 8 _int64 1636288 ._j 8 _int64 14106892 ._j
long long unsigned Default(signed) long long int 8 unsigned _int64 13674340 ._K 8 unsigned _int64 1636288 ._K 8 unsigned _int64 14106892 ._K
 signed int signed Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
 unsigned int unsigned Default int 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I
 char Default(signed) Default char 1 char 13674340 .D 1 char 1636288 .D 1 char 14106892 .D
 signed char signed Default char 1 signed char 13674340 .C 1 signed char 1636288 .C 1 signed char 14106892 .C
 unsigned char unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
 float Default Default float 4 float 13674340 .M 4 float 1636288 .M 4 float 14106892 .M
 long float Default long float 8 double 13674340 .N 8 double 1636288 .N 8 double 14106892 .N
 double Default Default double 8 double 13674340 .N 8 double 1636288 .N 8 double 14106892 .N
 long double Default long double 8 long double 13674340 .O 8 long double 1636288 .O 8 long double 14106892 .O
 bool Default Default Default 1 bool 13674340 ._N 1 bool 1636288 ._N 1 bool 14106892 ._N
 int* Default Default  int* 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
 char* Default Default char* 4 char * 13674340 .PAD 8 char * __ptr64 1636288 .PEAD 4 char * 14106892 .PAD
 float* Default Default float* 4 float * 13674340 .PAM 8 float * __ptr64 1636288 .PEAM 4 float * 14106892 .PAM
 double* Default Default double* 4 double * 13674340 .PAN 8 double * __ptr64 1636288 .PEAN 4 double * 14106892 .PAN
 wchar_t Default Default  wchar_t 2 wchar_t 13674340 ._W 2 wchar_t 1636288 ._W 2 wchar_t 14106892 ._W
 short * Default Default int * 4 short * 13674340 .PAF 8 short * __ptr64 1636288 .PEAF 4 short * 14106892 .PAF
 long*  Default Default int * 4 long * 13674340 .PAJ 8 long * __ptr64 1636288 .PEAJ 4 long * 14106892 .PAJ
 signed* Default(signed) Default int * 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
unsigned * unsigned Default int * 4 unsigned int * 13674340 .PAI 8 unsigned int * __ptr64 1636288 .PEAI 4 unsigned int * 14106892 .PAI
rsize_t unsigned Default int 4 unsigned int 13674340 .I 8 unsigned __int64 1636288 ._K 4 unsigned int 14106892 .I
size_t unsigned Default int 4 unsigned int 13674340 .I 8 unsigned __int64 1636288 ._K 4 unsigned int 14106892 .I
wchar_t Default Default wchar_t 2 wchar_t 13674340 ._W 2 wchar_t 1636288 ._W 2 wchar_t 14106892 ._W
_W64 int Default Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
_w64 int Default Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
BYTE unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
WORD unsigned Default int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
DWORD unsigned Default int 4 unsigned long 13674340 .K 4 unsigned long 1636288 .K 4 unsigned long 14106892 .K
UWORD unsigned Default int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
INT Default Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
INT8 signed Default char 1 signed char 13674340 .C 1 signed char 1636288 .C 1 signed char 14106892 .C
INT16 Default short int 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
INT32 Default Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
INT64 Default Default int 8 __int64 13674340 ._J 8 __int64 1636288 ._J 8 __int64 14106892 ._J
_LARGE_INTEGER Default Default int 8 union _LARGE_INTEGER 13674340 .?AT_LARGE_INTEGER@@ 8 union _LARGE_INTEGER 1636288 .?AT_LARGE_INTEGER@@ 8 union _LARGE_INTEGER 14106892 .?AT_LARGE_INTEGER@@
LARGE_INTEGER Default Default int 8 union _LARGE_INTEGER 13674340 .?AT_LARGE_INTEGER@@ 8 union _LARGE_INTEGER 1636288 .?AT_LARGE_INTEGER@@ 8 union _LARGE_INTEGER 14106892 .?AT_LARGE_INTEGER@@
UINT unsigned Default int 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I
UINT8 unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
UINT16 unsigned Default int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
UINT32 unsigned Default int 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I
UINT64 unsigned Default int 8 unsigned __int64 13674340 ._K 8 unsigned __int64 1636288 ._K 8 unsigned __int64 14106892 ._K
LONG Default long int 4 long 13674340 .J 4 long 1636288 .J 4 long 14106892 .J
LONG32 Default long int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
LONG64 Default long int 8 __int64 13674340 ._J 8 __int64 1636288 ._J 8 __int64 14106892 ._J
LONGLONG Default long int 8 __int64 13674340 ._J 8 __int64 1636288 ._J 8 __int64 14106892 ._J
ULONG unsigned long int 4 unsigned long 13674340 .K 4 unsigned long 1636288 .K 4 unsigned long 14106892 .K
ULONG32 unsigned long int 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I
ULONG64 unsigned long int 8 unsigned __int64 13674340 ._K 8 unsigned __int64 1636288 ._K 8 unsigned __int64 14106892 ._K
ULONGLONG unsigned long int 8 unsigned __int64 13674340 ._K 8 unsigned __int64 1636288 ._K 8 unsigned __int64 14106892 ._K
SHORT Default short int 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
USHORT Default short int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
CHAR Default Default char 1 char 13674340 .D 1 char 1636288 .D 1 char 14106892 .D
UCHAR unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
BCHAR unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
CCHAR Default Default char 1 char 13674340 .D 1 char 1636288 .D 1 char 14106892 .D
UCSCHAR unsigned long int 4 unsigned long 13674340 .K 4 unsigned long 1636288 .K 4 unsigned long 14106892 .K
UHALF_PTR unsigned short int 2 unsigned short 13674340 .G 4 unsigned int 1636288 .I 2 unsigned short 14106892 .G
HALF_PTR Default short int 2 short 13674340 .F 4 int 1636288 .H 2 short 14106892 .F
INT_PTR Default Default int 4 int 13674340 .H 8 __int64 1636288 ._J 4 int 14106892 .H
LONG_PTR Default long int 4 long 13674340 .J 8 __int64 1636288 ._J 4 long 14106892 .J
FLOAT Default Default float 4 float 13674340 .M 4 float 1636288 .M 4 float 14106892 .M
FLOAT128 Default Default float 16 struct _FLOAT128 13674340 .?AU_FLOAT128@@ 16 struct _FLOAT128 1636288 .?AU_FLOAT128@@ 16 struct _FLOAT128 14106892 .?AU_FLOAT128@@
_FLOAT128 Default Default float 16 struct _FLOAT128 13674340 .?AU_FLOAT128@@ 16 struct _FLOAT128 1636288 .?AU_FLOAT128@@ 16 struct _FLOAT128 14106892 .?AU_FLOAT128@@
DOUBLE Default Default Double 8 double 13674340 .N 8 double 1636288 .N 8 double 14106892 .N
_LONGDOUBLE Default long Double 8 struct _LONGDOUBLE 13674340 .?AU_LONGDOUBLE@@ 8 struct _LONGDOUBLE 1636288 .?AU_LONGDOUBLE@@ 8 struct _LONGDOUBLE 14106892 .?AU_LONGDOUBLE@@
_LONGDOUBLE Default long Double 8 struct _LONGDOUBLE 13674340 .?AU_LONGDOUBLE@@ 8 struct _LONGDOUBLE 1636288 .?AU_LONGDOUBLE@@ 8 struct _LONGDOUBLE 14106892 .?AU_LONGDOUBLE@@
uint8_t unsigned Default char 1 unsigned char 13674340 .E 1 unsigned char 1636288 .E 1 unsigned char 14106892 .E
uint16_t unsigned short int 2 unsigned short 13674340 .G 2 unsigned short 1636288 .G 2 unsigned short 14106892 .G
uint32_t unsigned Default int 4 unsigned int 13674340 .I 4 unsigned int 1636288 .I 4 unsigned int 14106892 .I
uint64_t unsigned Default int 8 unsigned __int64 13674340 ._K 8 unsigned __int64 1636288 ._K 8 unsigned __int64 14106892 ._K
 __int8 Default Default char 1 char 13674340 .D 1 char 1636288 .D 1 char 14106892 .D
 __int16 Default short int 2 short 13674340 .F 2 short 1636288 .F 2 short 14106892 .F
 __int32 Default Default int 4 int 13674340 .H 4 int 1636288 .H 4 int 14106892 .H
 __int64 Default Default int 8 __int64 13674340 ._J 8 __int64 1636288 ._J 8 __int64 14106892 ._J
PBYTE unsigned Default char* 4 unsigned char * 13674340 .PAE 8 unsigned char * __ptr64 1636288 .PEAE 4 unsigned char * 14106892 .PAE
PWORD unsigned short int* 4 unsigned short * 13674340 .PAG 8 unsigned short * __ptr64 1636288 .PEAG 4 unsigned short * 14106892 .PAG
PDWORD unsigned Long int* 4 unsigned long * 13674340 .PAK 8 unsigned long * __ptr64 1636288 .PEAK 4 unsigned long * 14106892 .PAK
PINT Default Default int* 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
PINT8 signed Default char* 4 signed char * 13674340 .PAC 8 signed char * __ptr64 1636288 .PEAC 4 signed char * 14106892 .PAC
PINT16 Default short int* 4 short * 13674340 .PAF 8 short * __ptr64 1636288 .PEAF 4 short * 14106892 .PAF
PINT32 Default Default int* 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
PINT64 Default Default int* 4 __int64 * 13674340 .PA_J 8 __int64 * __ptr64 1636288 .PEA_J 4 __int64 * 14106892 .PA_J
PULARGE_INTEGER Default Default int* 4 union _ULARGE_INTEGER * 13674340 .PAT_ULARGE_INTEGER@@ 8 union _ULARGE_INTEGER * __ptr64 1636288 .PEAT_ULARGE_INTEGER@@ 4 union _ULARGE_INTEGER * 14106892 .PAT_ULARGE_INTEGER@@
PUINT unsigned Default int* 4 unsigned int * 13674340 .PAI 8 unsigned int * __ptr64 1636288 .PEAI 4 unsigned int * 14106892 .PAI
PUINT8 unsigned Default char* 4 unsigned char * 13674340 .PAE 8 unsigned char * __ptr64 1636288 .PEAE 4 unsigned char * 14106892 .PAE
PUINT16 unsigned short int* 4 unsigned short * 13674340 .PAG 8 unsigned short * __ptr64 1636288 .PEAG 4 unsigned short * 14106892 .PAG
PUINT32 unsigned Default int* 4 unsigned int * 13674340 .PAI 8 unsigned int * __ptr64 1636288 .PEAI 4 unsigned int * 14106892 .PAI
PUINT64 unsigned Default int* 4 unsigned __int64 * 13674340 .PA_K 8 unsigned __int64 * __ptr64 1636288 .PEA_K 4 unsigned __int64 * 14106892 .PA_K
PLONG Default Long int* 4 long * 13674340 .PAJ 8 long * __ptr64 1636288 .PEAJ 4 long * 14106892 .PAJ
PLONG32 Default Default int* 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
PLONG64 Default Default int* 4 __int64 * 13674340 .PA_J 8 __int64 * __ptr64 1636288 .PEA_J 4 __int64 * 14106892 .PA_J
PLONGLONG Default Default int* 4 __int64 * 13674340 .PA_J 8 __int64 * __ptr64 1636288 .PEA_J 4 __int64 * 14106892 .PA_J
PULONG unsigned Long int* 4 unsigned long * 13674340 .PAK 8 unsigned long * __ptr64 1636288 .PEAK 4 unsigned long * 14106892 .PAK
PULONG32 unsigned Default int* 4 unsigned int * 13674340 .PAI 8 unsigned int * __ptr64 1636288 .PEAI 4 unsigned int * 14106892 .PAI
PULONG64 unsigned Default int* 4 unsigned __int64 * 13674340 .PA_K 8 unsigned __int64 * __ptr64 1636288 .PEA_K 4 unsigned __int64 * 14106892 .PA_K
PULONGLONG unsigned Default int* 4 unsigned __int64 * 13674340 .PA_K 8 unsigned __int64 * __ptr64 1636288 .PEA_K 4 unsigned __int64 * 14106892 .PA_K
PSHORT Default short int* 4 short * 13674340 .PAF 8 short * __ptr64 1636288 .PEAF 4 short * 14106892 .PAF
PUSHORT unsigned short int* 4 unsigned short * 13674340 .PAG 8 unsigned short * __ptr64 1636288 .PEAG 4 unsigned short * 14106892 .PAG
PCH Default Default Char* 4 char * 13674340 .PAD 8 char * __ptr64 1636288 .PEAD 4 char * 14106892 .PAD
PCHAR Default Default Char* 4 char * 13674340 .PAD 8 char * __ptr64 1636288 .PEAD 4 char * 14106892 .PAD
PUCHAR unsigned Default Char* 4 unsigned char * 13674340 .PAE 8 unsigned char * __ptr64 1636288 .PEAE 4 unsigned char * 14106892 .PAE
PUCSCHAR unsigned Long int* 4 unsigned long * 13674340 .PAK 8 unsigned long * __ptr64 1636288 .PEAK 4 unsigned long * 14106892 .PAK
PUCSSTR unsigned Long int* 4 unsigned long * 13674340 .PAK 8 unsigned long * __ptr64 1636288 .PEAK 4 unsigned long * 14106892 .PAK
PSHORT Default short int* 4 short * 13674340 .PAF 8 short * __ptr64 1636288 .PEAF 4 short * 14106892 .PAF
PLONG Default Long int* 4 long * 13674340 .PAJ 8 long * __ptr64 1636288 .PEAJ 4 long * 14106892 .PAJ
PUHALF_PTR unsigned short int* 4 unsigned short * 13674340 .PAG 8 unsigned int * __ptr64 1636288 .PEAI 4 unsigned short * 14106892 .PAG
PHALF_PTR Default short int* 4 short * 13674340 .PAF 8 int * __ptr64 1636288 .PEAH 4 short * 14106892 .PAF
PINT_PTR Default Default int* 4 int * 13674340 .PAH 8 __int64 * __ptr64 1636288 .PEA_J 4 int * 14106892 .PAH
PLONG_PTR Default Long int* 4 long * 13674340 .PAJ 8 __int64 * __ptr64 1636288 .PEA_J 4 long * 14106892 .PAJ
LPVOID Default Default void * 4 void * 13674340 .PAX 8 void * __ptr64 1636288 .PEAX 4 void * 14106892 .PAX
LPCVOID Default Default void const* 4 void const * 13674340 .PBX 8 void const * __ptr64 1636288 .PEBX 4 void const * 14106892 .PBX
LPBYTE unsigned Default Char* 4 unsigned char * 13674340 .PAE 8 unsigned char * __ptr64 1636288 .PEAE 4 unsigned char * 14106892 .PAE
LPBOOL Default Default int* 4 int * 13674340 .PAH 8 int * __ptr64 1636288 .PEAH 4 int * 14106892 .PAH
LPBSTR Default Default wchar_t * * 4 wchar_t * * 13674340 .PAPA_W 8 wchar_t * __ptr64 * __ptr64 1636288 .PEAPEA_W 4 wchar_t * * 14106892 .PAPA_W
LPCBYTE unsigned Default char const * 4 unsigned char const * 13674340 .PBE 8 unsigned char const * __ptr64 1636288 .PEBE 4 unsigned char const * 14106892 .PBE
LPCCH Default Default char const * 4 char const * 13674340 .PBD 8 char const * __ptr64 1636288 .PEBD 4 char const * 14106892 .PBD
LPCSTR Default Default char const * 4 char const * 13674340 .PBD 8 char const * __ptr64 1636288 .PEBD 4 char const * 14106892 .PBD
LPCTSTR Default Default char const * 4 char const * 13674340 .PBD 8 char const * __ptr64 1636288 .PEBD 4 char const * 14106892 .PBD
LPCTCH Default Default char const * 4 char const * 13674340 .PBD 8 char const * __ptr64 1636288 .PEBD 4 char const * 14106892 .PBD
LPCUTSTR Default Default char const * 4 char const * 13674340 .PBD 8 char const * __ptr64 1636288 .PEBD 4 char const * 14106892 .PBD
LPCUWCHAR Default Default wchar_t const * 4 wchar_t const * 13674340 .PB_W 8 wchar_t const __unaligned * __ptr64 1636288 .PEFB_W 4 wchar_t const * 14106892 .PB_W
LPCUWSTR Default Default wchar_t const * 4 wchar_t const * 13674340 .PB_W 8 wchar_t const __unaligned * __ptr64 1636288 .PEFB_W 4 wchar_t const * 14106892 .PB_W
LPCWCH Default Default wchar_t const * 4 wchar_t const * 13674340 .PB_W 8 wchar_t const * __ptr64 1636288 .PEB_W 4 wchar_t const * 14106892 .PB_W
LPCWCHAR Default Default wchar_t const * 4 wchar_t const * 13674340 .PB_W 8 wchar_t const * __ptr64 1636288 .PEB_W 4 wchar_t const * 14106892 .PB_W
LPCWSTR Default Default wchar_t const * 4 wchar_t const * 13674340 .PB_W 8 wchar_t const * __ptr64 1636288 .PEB_W 4 wchar_t const * 14106892 .PB_W
LPLONG Default Long int* 4 long * 13674340 .PAJ 8 long * __ptr64 1636288 .PEAJ 4 long * 14106892 .PAJ
LPSTR Default Default char* 4 char * 13674340 .PAD 8 char * __ptr64 1636288 .PEAD 4 char * 14106892 .PAD



                            

No comments:

Post a Comment