Re: iostreams and Performer

New Message Reply Date view Thread view Subject view Author view

Dirk Luesebrink (crux++at++artcom.de)
Tue, 02 Dec 1997 16:12:37 +0100


C++ and C have a different init function. when you stop your executable
in main and look to the call stack you can see from where main is
called. this startup code is put into your executable by the linker. for
'C' you use /usr/bin/cc or /usr/bin/ld, for 'C++' you should/must use
/usr/bin/CC. the startup function are then taken from either libc.so or
libC.so. for 'C++' programs, before your main is called, this function
performs the static initialization. because iostream depends on some
static variables your program will crash if not linked with /usr/bin/CC.
to call the static init function of iostreams yourself resolves that
problem but you never now what kind of trouble is still in there you
didnt notice yet. I would not recommend that approach. the typical
example performer Makefile easily gets confused for C++ programs and
uses /usr/bin/cc instead of /usr/bin/CC. i think you can override this
behaviour with LD = /usr/bin/CC in your Makefile. this would work for
plain 'C' programs as well, because /usr/bin/CC is not the linker itself
but only a frontend driver which figures out what to do. how that
relates to being combined with jave i cant say because i havent tried it
yet.

dirk

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
=======================================================================
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.