constructors created twice in object files
Rogelio M. Serrano Jr.
rogelio@evoserve.com
Mon Jan 14 15:31:00 GMT 2002
Why are constructors generated twice when compiling?
for example:
#ifndef __Q_BOOT_OBJ____
#define __Q_BOOT_OBJ____
class boot_obj
{
public:
static char* top_of_heap;
boot_obj() throw();
boot_obj(boot_obj& x) throw();
void* boot_alloc(unsigned int) throw();
};
#include "boot_obj"
extern "C" char* _end;
boot_obj::boot_obj() throw ()
{
bool started = false;
if (!started)
{
top_of_heap = reinterpret_cast<char*>((reinterpret_cast<unsigned int>(_end) + 0x01) & ~0x01);
started = false;
}
}
boot_obj::boot_obj(boot_obj& x) throw ()
{
}
void* boot_obj::boot_alloc(unsigned int sz) throw ()
{
void* ret = top_of_heap;
top_of_heap += ((sz + 0x01) & ~0x01);
return ret;
}
I get this after compiling:
00000058 T _ZN8boot_obj10boot_allocEj
U _ZN8boot_obj11top_of_heapE
00000050 T _ZN8boot_objC1ERS_
00000024 T _ZN8boot_objC1Ev
00000048 T _ZN8boot_objC2ERS_
00000000 T _ZN8boot_objC2Ev
U _end
More information about the Gcc-help
mailing list