Skip to content

Instantly share code, notes, and snippets.

@uhziel
Created September 21, 2020 10:09
Show Gist options
  • Save uhziel/52af43f2d99a1b4c47d9eda1922b5634 to your computer and use it in GitHub Desktop.
Save uhziel/52af43f2d99a1b4c47d9eda1922b5634 to your computer and use it in GitHub Desktop.
#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;
}
@uhziel
Copy link
Author

uhziel commented Sep 21, 2020

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