problem using C++ classes with AIX xlc Version 5.0

C

ChrisG

Hi,

I am building an executable on a bunch of UNIX platforms. It works on
all the other ones
(HP, Linux, SUN, SGI) but fails to run on Aix with xlc compiler version
5.0. The problem
is that the default constructors of my global objects are not called on
this platform. So
I declared my global object as

SymbolTable globalSymTab ;

and SymbolTable.cpp has

SymbolTable::SymbolTable ()
: m_curId (0),
m_htab (hTabSize),
m_offStr (0),
m_type (0) {
}

while SymbolTable.hpp has

class SymbolTable {

public:

SymbolTable ();
...
}

But the constructor SymbolTable::SymbolTable () is never called. Could
anyone give
me some suggestions on this problem?

Thanks in advance,
Chris
 
T

Thomas Tutone

ChrisG said:
Hi,

I am building an executable on a bunch of UNIX platforms. It works on
all the other ones
(HP, Linux, SUN, SGI) but fails to run on Aix with xlc compiler version
5.0. The problem
is that the default constructors of my global objects are not called on
this platform. So
I declared my global object as

SymbolTable globalSymTab ;

and SymbolTable.cpp has

SymbolTable::SymbolTable ()
: m_curId (0),
m_htab (hTabSize),
m_offStr (0),
m_type (0) {
}

while SymbolTable.hpp has

class SymbolTable {

public:

SymbolTable ();
...
}

But the constructor SymbolTable::SymbolTable () is never called. Could
anyone give
me some suggestions on this problem?

Hard to tell without more info. Given that you are using global
variables and your code works on some platforms but not others, It is
possible that you are falling victim to the static initialization order
fiasco - in which case, you will find the following FAQ entries
helpful:

http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12

Best regards,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top