好文, 与当年我看《深度探索c++对象模型》时的困惑一样,当时看的也是云里雾里。
https://blog.csdn.net/shichao1470/article/details/91563282
有一点要说明一下, 现在最新的g++编译器,dump出c++类对象内存布局的编译选项,应该变为:-fdump-lang-class
, 而不是链接中的 -fdump-class-hierarchy
选项, 最起码在我电脑上是这样的, 查看了在最新的gcc官方手册上, 也是这样的, 说明如下:
-fdump-lang-all
-fdump-lang-switch
-fdump-lang-switch-options
-fdump-lang-switch-options=filename
Control the dumping of language-specific information. The options and filename portions behave as described in the ‘-fdump-tree’ option. The following
switch values are accepted:
‘all’
Enable all language-specific dumps.
‘class’ Dump class hierarchy information. Virtual table information is
emitted unless ’‘slim’’ is specified. This option is applicable to
C++ only.
‘raw’ Dump the raw internal tree data. This option is applicable to C++
only.