- 論壇徽章:
- 2
|
- $ g++ -fdump-class-hierarchy
復(fù)制代碼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
復(fù)制代碼
- $ 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
復(fù)制代碼 建議將代碼改成這樣再去試:
- 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);
- }
- }
復(fù)制代碼 |
|