Trying to understand what's going on with symbol table when class constructor/destructor is inlined vs implemented in .cpp file. Here's the code:
class.hpp
class Class
{
public:
#ifdef CUSTOM_CTOR
#ifdef HEADER_IMPL
Class(){ }
virtual ~Class(){}
#else
Class();
virtual ~Class();
#endif
#endif
private:
void init();
};
class.cpp
#include "class.hpp"
#ifdef CUSTOM_CTOR
#ifndef HEADER_IMPL
Class::Class () {}
Class::~Class() {}
#endif
#endif
void Class::init(){ }
I compile code into object file and then inspect it with nm
. Here are the results:
$ clang++ class.cpp -c -DCUSTOM_CTOR -DHEADER_IMPL -o class.o
$ nm class.o
0000000000000000 T __ZN5Class4initEv
$ clang++ class.cpp -c -DCUSTOM_CTOR -o class.o
$ nm class.o
00000000000000cc s GCC_except_table4
U __Unwind_Resume
00000000000000c0 T __ZN5Class4initEv
0000000000000020 T __ZN5ClassC1Ev
0000000000000000 T __ZN5ClassC2Ev
0000000000000070 T __ZN5ClassD0Ev
0000000000000050 T __ZN5ClassD1Ev
0000000000000040 T __ZN5ClassD2Ev
00000000000000f8 S __ZTI5Class
0000000000000108 S __ZTS5Class
00000000000000d8 S __ZTV5Class
U __ZTVN10__cxxabiv117__class_type_infoE
U __ZdlPv
U ___gxx_personality_v0
Symbol table for the code when constructor and destructor are inlined doesn't have any typeinfo
nor vtable
. Why is this happening (macOS platform)?
(also, compiling with default construtor/destructor yields results as in the case with inlined constructor).