problem using C++ classes with AIX xlc Version 5.0

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ChrisG

    #1

    problem using C++ classes with AIX xlc Version 5.0

    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::Sy mbolTable ()
    : m_curId (0),
    m_htab (hTabSize),
    m_offStr (0),
    m_type (0) {
    }

    while SymbolTable.hpp has

    class SymbolTable {

    public:

    SymbolTable ();
    ...
    }

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

    Thanks in advance,
    Chris

  • Thomas Tutone

    #2
    Re: problem using C++ classes with AIX xlc Version 5.0


    ChrisG wrote:[color=blue]
    > 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::Sy mbolTable ()
    > : m_curId (0),
    > m_htab (hTabSize),
    > m_offStr (0),
    > m_type (0) {
    > }
    >
    > while SymbolTable.hpp has
    >
    > class SymbolTable {
    >
    > public:
    >
    > SymbolTable ();
    > ...
    > }
    >
    > But the constructor SymbolTable::Sy mbolTable () is never called. Could
    > anyone give
    > me some suggestions on this problem?[/color]

    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:



    Best regards,

    Tom

    Comment

    Working...