Unix Technical Forum

problem with default constructor of global object on AIX with xlc 5.0

This is a discussion on problem with default constructor of global object on AIX with xlc 5.0 within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I have a simple code: ================================================== #include <iostream.h> class InstructionSet { public: InstructionSet() { cerr << "InstructionSet CONSTRUCTOR\n"; ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 01-05-2008, 08:00 AM
ChrisG
 
Posts: n/a
Default problem with default constructor of global object on AIX with xlc 5.0

Hi,

I have a simple code:

==================================================
#include <iostream.h>

class InstructionSet
{
public:
InstructionSet() {
cerr << "InstructionSet CONSTRUCTOR\n";
}
~InstructionSet() {
cerr << "InstructionSet DESTROYED\n";
}
};

InstructionSet globalInstructionSet;

int main(int argc, char * argv[])
{
cerr << "main\n";
return 0;
}
==================================================

When I built and ran this on IBM AIX with xlc version 5, I got

main

But on the other UNIX platforms (HP, SGI, Alpha, Linux, SUN), I got

InstructionSet CONSTRUCTOR
main
InstructionSet DESTROYED

Do you know why the Aix build is not calling the default constructor?

The build commands on Aix are

Compiling rdc.cpp
xlc -q64 -O2 -DAIX5 -DRS64 -DRS6000 -qnolm -DUSE_AIX_LOCAL -c
-o rdc.o rdc.cpp -I. -Iunix -I../../include/
Creating rdc
xlc -q64 -O2 -DAIX5 -DRS64 -DRS6000 -qnolm -DUSE_AIX_LOCAL -o
rdc rdc.o -bh:4 -bpT:0x10000000 -bpD:0x200000 -L. -L../../bin/ -lbsd

-q64 -lpthreads -lC -lC -lc -lxlf90 -lm

Many thanks in advance,
Chris

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 08:00 AM
Paul Pluzhnikov
 
Posts: n/a
Default Re: problem with default constructor of global object on AIX withxlc 5.0

"ChrisG" <arcticdream00@yahoo.com> writes:

> Do you know why the Aix build is not calling the default constructor?


Because you are not building your executable correctly.

> xlc -q64 ... -q64 -lpthreads -lC -lC -lc -lxlf90 -lm


Never do this ^^^^^^^^^^^^

Instead, use appropriate compiler driver ('xlC' in this case)
to link your executables.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 08:00 AM
ChrisG
 
Posts: n/a
Default Re: problem with default constructor of global object on AIX with xlc 5.0

Thanks a lot! Using xlC solved the problem.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.unixadmintalk.com/aix-operating-system/6153-problem-default-constructor-global-object-aix-xlc-5-0-a.html

Posted By For Type Date
AIX Operating System [Archive] - Page 17 - Unix Technical Forum This thread Refback 07-01-2008 02:59 AM


All times are GMT. The time now is 05:53 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com