Re: iostreams in 2.0

New Message Reply Date view Thread view Subject view Author view

Kent Watsen (watsen++at++coryphaeus.com)
Thu, 30 Nov 95 10:54:53 -0800


>
> > You have to #include <iostream.h> and link with the C++ compiler...
> > or be sure to instantiate an instance of Iostream_init before your
> > first iostream call.
>
> *Any* application that includes object files or libraries that rely
> on the construction of static instances of C++ objects must perform
> the final link with CC or else the objects will not be constructed.
> Internally, IRIS Performer 2.0 does not rely on static construction
> so as far as libpf itself is concerned either CC or cc works.
>

Ah, but the final link doesn't have to be performed be CC, as the code
following demonstrates:

test.c++:

#include <iostream.h>
extern "C" { void test_cpp(void); }
void test_cpp(void
{
  Iostream_init tmp;
  cout << "testing" << endl;
}

main.c:

#include <stdio.h>
extern void test_cpp(void);
main()
{
  printf ("test before\n");
  test_cpp();
  printf ("test after\n");
}

% CC -c test.c++
% cc main.c test.o -lC

 % a.out
test before
testing
test after

Without the instantiation of an Iostream_init the program would
have incurred a segmentation fault. Note that the instantiation
of the Iostream_init could not have been done globally (as CC
would do for you).

             ___________________________________________
             -------------------------------------------
|| || || Kent Watsen || || ||
|| || || Coryphaeus Software || || ||
|| || || 408.395.4537 x223 || || ||
|| || || watsen++at++coryphaeus.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:52:04 PDT

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