Re: iostreams and Performer

New Message Reply Date view Thread view Subject view Author view

Chris Henderson (ch++at++paradigmsim.com)
Tue, 02 Dec 1997 09:26:56 -0600


Another answer posted to InfoPerformer was the following:

>Any program that uses iostreams must be linked with CC rather than cc
>so that the initialization object Iostream_init
>will be constructed (see iostream.h).
>In fact, any program that has any static or external C++ objects with
>constructors must be linked with CC instead of cc.

>None of the examples use iostreams (which is why we didn't notice the problem),
>but the Makefiles in the C++ example directories should be changed to use
>$(CXX) instead of $(CC).

>Don

>--
>Don Hatch hatch++at++sgi.com (415) 933-5150 Silicon Graphics, Inc.

ch

Prakash Mahesh wrote:
>
> Gordon Tomlinson wrote:
> >
> > Hi Guys
> >
> > We are experiencing problems with using iostreams and performer.
> >
> > ie simple cout cause a segmentation fault
> >
> > My colleague remmebers some postings on the issue some time agom some thing about
> > the default constructor not being called but we cannot find references in the archives.
> >
> > Has any kind sole got any info on this or a pointer to the location of any info.
>
> I am not sure what exactly you were trying to do, but this is what I was
> doing, when I got into similar problems.
>
> My application starts with Java (where the main function is), and using
> Java Native Interface, I got into C, and then C++, and eventually called
> Performer functions. And in this case, everytime, it encountered an
> iostream call, it was crashing.
>
> After lot of research, we found that it was a simple C++ issue. Just
> before main() function is called, the global constructors are called,
> thereby initializing the iostream stuff. In my case, there was no main()
> in the C/C++ side (it was in the Java side). So, the initizlizations
> were never done.
>
> So, this is going to happen, whenever you don't have a C/C++ main() in
> your application. This has nothing to do with Performer (as far as I
> know).
>
> There is a workaround (assuming that this is what your problem is). From
> tha documentation for CC/ld you can see that you can do the
> initializations yourself as below:
>
> #include <iostream.h>
>
> extern Iostream_init *io;
>
> io = Iostream_init();
>
> The first two lines comes all the way in the beginning of your first C++
> file, and the third line (please check the exact syntax) probably before
> any cerr/cout/cin.
>
> Hope this helps.
>
> --
> Prakash Mahesh
> prakash++at++drawcomp.com
> --or--
> prakash++at++openworlds.com
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

-- 
Chris Henderson ~ Paradigm Simulation Inc
Lead Software Engineer-ASF/PLT-V Simulator
(972) 960-2301 FAX (972) 960-2303
mailto:ch++at++paradigmsim.com
http://www.paradigmsim.com
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:19 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.