| 1 |
// Compile with "cl /c /Zi /GR- /EHsc test-pdb-types.cpp" |
| 2 |
// Link with "link test-pdb-types.obj /debug /nodefaultlib /entry:main |
| 3 |
// /out:test-pdb-types.exe" |
| 4 |
|
| 5 |
// Sizes of builtin types |
| 6 |
static const int sizeof_char = sizeof(char); |
| 7 |
static const int sizeof_uchar = sizeof(unsigned char); |
| 8 |
static const int sizeof_short = sizeof(short); |
| 9 |
static const int sizeof_ushort = sizeof(unsigned short); |
| 10 |
static const int sizeof_int = sizeof(int); |
| 11 |
static const int sizeof_uint = sizeof(unsigned int); |
| 12 |
static const int sizeof_long = sizeof(long); |
| 13 |
static const int sizeof_ulong = sizeof(unsigned long); |
| 14 |
static const int sizeof_longlong = sizeof(long long); |
| 15 |
static const int sizeof_ulonglong = sizeof(unsigned long long); |
| 16 |
static const int sizeof_int64 = sizeof(__int64); |
| 17 |
static const int sizeof_uint64 = sizeof(unsigned __int64); |
| 18 |
static const int sizeof_float = sizeof(float); |
| 19 |
static const int sizeof_double = sizeof(double); |
| 20 |
static const int sizeof_bool = sizeof(bool); |
| 21 |
static const int sizeof_wchar = sizeof(wchar_t); |
| 22 |
|
| 23 |
enum Enum { |
| 24 |
EValue1 = 1, |
| 25 |
EValue2 = 2, |
| 26 |
}; |
| 27 |
|
| 28 |
enum ShortEnum : short { ESValue1 = 1, ESValue2 = 2 }; |
| 29 |
|
| 30 |
namespace NS { |
| 31 |
class NSClass { |
| 32 |
float f; |
| 33 |
double d; |
| 34 |
}; |
| 35 |
} // namespace NS |
| 36 |
|
| 37 |
class Class { |
| 38 |
public: |
| 39 |
class NestedClass { |
| 40 |
Enum e; |
| 41 |
}; |
| 42 |
ShortEnum se; |
| 43 |
}; |
| 44 |
|
| 45 |
int test_func(int a, int b) { return a + b; } |
| 46 |
|
| 47 |
typedef Class ClassTypedef; |
| 48 |
typedef NS::NSClass NSClassTypedef; |
| 49 |
typedef int (*FuncPointerTypedef)(); |
| 50 |
typedef int (*VariadicFuncPointerTypedef)(char, ...); |
| 51 |
FuncPointerTypedef GlobalFunc; |
| 52 |
VariadicFuncPointerTypedef GlobalVariadicFunc; |
| 53 |
int GlobalArray[10]; |
| 54 |
|
| 55 |
static const int sizeof_NSClass = sizeof(NS::NSClass); |
| 56 |
static const int sizeof_Class = sizeof(Class); |
| 57 |
static const int sizeof_NestedClass = sizeof(Class::NestedClass); |
| 58 |
static const int sizeof_Enum = sizeof(Enum); |
| 59 |
static const int sizeof_ShortEnum = sizeof(ShortEnum); |
| 60 |
static const int sizeof_ClassTypedef = sizeof(ClassTypedef); |
| 61 |
static const int sizeof_NSClassTypedef = sizeof(NSClassTypedef); |
| 62 |
static const int sizeof_FuncPointerTypedef = sizeof(FuncPointerTypedef); |
| 63 |
static const int sizeof_VariadicFuncPointerTypedef = |
| 64 |
sizeof(VariadicFuncPointerTypedef); |
| 65 |
static const int sizeof_GlobalArray = sizeof(GlobalArray); |
| 66 |
|
| 67 |
int main(int argc, char **argv) { |
| 68 |
ShortEnum e1; |
| 69 |
Enum e2; |
| 70 |
Class c1; |
| 71 |
Class::NestedClass c2; |
| 72 |
NS::NSClass c3; |
| 73 |
|
| 74 |
ClassTypedef t1; |
| 75 |
NSClassTypedef t2; |
| 76 |
return test_func(1, 2); |
| 77 |
} |