Back to index

cell-binutils  2.17cvs20070401
cdtest-main.cc
Go to the documentation of this file.
00001 // main program for Class Foo
00002 
00003 extern "C" {
00004 // Some <assert.h> implementations (e.g. SUNOS 4.1) are broken,
00005 // in that they require <stdio.h>.  But, if gcc/g++ is installed
00006 // correctly, you should get gcc's assert.h.
00007 // If the compile fails, it means the wrong include files are in use!
00008 #include <assert.h>
00009 };
00010 #include "cdtest-foo.h"
00011 
00012 extern "C" void __init_start();
00013 
00014 extern Foo f(void);
00015 extern void g(void);
00016 
00017 /* This function should *not* be called by the environment.  There is
00018    no way in C++ to ``run something after the initializers but before main()''.
00019    The library that depends on this (NIHCL) is broken.  -- John Gilmore 
00020    We leave this here to test that future changes to the compiler
00021    do not re-introduce this losing ``feature''.  */
00022 void 
00023 __init_start()
00024 {
00025     Foo::init_foo();
00026 }
00027 
00028 static Foo static_foo( "static_foo"); 
00029 
00030 int main() 
00031 { 
00032     assert (Foo::nb_foos() == 2);
00033     Foo automatic_foo( "automatic_foo");
00034     Foo bla_foo = f();
00035     assert (Foo::nb_foos() == 4);
00036     g();
00037     assert (Foo::nb_foos() == 4);
00038     // `automatic_foo' and `bla_foo' are destructed here 
00039 } 
00040