Created
September 21, 2020 10:09
-
-
Save uhziel/52af43f2d99a1b4c47d9eda1922b5634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> // std::cout | |
enum FruitType | |
{ | |
Apple, | |
Pear, | |
}; | |
int main () { | |
FruitType enum_type = Pear; | |
int int_type = 0; | |
std::cout << "sizeof(FruitType)" << sizeof(enum_type) << std::endl; | |
std::cout << "sizeof(int_type)" << sizeof(int_type) << std::endl; | |
return 0; | |
} |
D:\workspace>cl size.cpp
用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.15.26730 版
版权所有(C) Microsoft Corporation。保留所有权利。
size.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\xlocale(319): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc
Microsoft (R) Incremental Linker Version 14.15.26730.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:size.exe
size.obj
D:\workspace>size.exe
sizeof(FruitType)4
sizeof(int_type)4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[root@TENCENT64 /tmp]# g++ size.cpp
[root@TENCENT64 /tmp]# ./a.out
sizeof(FruitType)4
sizeof(int_type)4
[root@TENCENT64 /tmp]# g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-5)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.