- 论坛徽章:
- 2
|
- $ g++ -fdump-class-hierarchy
复制代码http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
-fdump-class-hierarchy (C++ only)
-fdump-class-hierarchy-options (C++ only)
Dump a representation of each class's hierarchy and virtual function table layout to a file. The file name is made by appending .class to the source file name, and the file is created in the same directory as the output file. If the ‘-options’ form is used, options controls the details of the dump as described for the -fdump-tree options.
- $ cl /d1reportAllClassLayout
复制代码
- $ clang -cc1 --help | grep layouts
- -fdump-record-layouts Dump record layout information
- -fdump-vtable-layouts Dump the layouts of all vtables that will be emitted in a translation unit
复制代码 建议将代码改成这样再去试:
- class ca { public: virtual ~ca() {} };
- class cb { public: virtual ~cb() {} };
- class cc : public ca, public cb { public: virtual ~cc() {} };
- class cd: public cc { public: virtual ~cd() {} };
- int main(int argc, char* argv[])
- {
- switch (argc)
- {
- default: return 0;
- case 1: return sizeof(ca);
- case 2: return sizeof(cb);
- case 3: return sizeof(cc);
- case 4: return sizeof(cd);
- }
- }
复制代码 |
|