[comp.sys.mac.programmer] C++ and StandAlone code

louis@asterix.drev.dnd.ca (Louis Demers) (09/15/90)

Hello,

	We are working on a project involving MacApp 2.0, C++ 3.1b1
and A/ROSE ( on a card from GreenSpring Computers).

	We would like to write the A/ROSE executable in C++. So far we
have had only limited succes.  We were able to succesfully execute the
following:

	a) a standard C program compiled with the C++ compiler.
	b) a C++ program without any virtual functions

	We were NOT able to get a C++ program with virtual functions
to execute properly. When the virtual function got called, the card
crashed.

	What piece of code is responsible for the initialization and
maintenance of the virtual functions tables ?  We suspect that by
linking the libraries from GreenSpring, some of that code is not 
executed.
 
	 Has anybody written stand alone code in C++ that uses
 virtual functions ?


+---------------------------+-------------------------------------------------+
| Louis Demers              | DREV, Defence Research Establishment,Valcartier |
| louis@asterix.drev.dnd.ca | POBox 8800, Courcelette,Quebec, CANADA, G0A 1R0 |
|            (131.132.48.2) | Office: (418) 844-4424       fax (418) 844-4511 |
+---------------------------+-------------------------------------------------+
-- 
| Louis Demers              | DREV, Defence Research Establishment,Valcartier |
| louis@asterix.drev.dnd.ca | POBox 8800, Courcelette,Quebec, CANADA, G0A 1R0 |
|            (131.132.48.2) | Office: (418) 844-4424       fax (418) 844-4511 |
+---------------------------+-------------------------------------------------+

pierre@iti.org (Pierre Omidyar) (09/18/90)

louis@asterix.drev.dnd.ca (Louis Demers) writes:


>Hello,

>	We are working on a project involving MacApp 2.0, C++ 3.1b1
>and A/ROSE ( on a card from GreenSpring Computers).

>	We would like to write the A/ROSE executable in C++. So far we
>have had only limited succes.  We were able to succesfully execute the
>following:

>	a) a standard C program compiled with the C++ compiler.
>	b) a C++ program without any virtual functions

>	We were NOT able to get a C++ program with virtual functions
>to execute properly. When the virtual function got called, the card
>crashed.

Here is where you have your problem:  to implement virtual functions, C++
requires static vtables.  Since MPW does not automatically support the use
of globals in non-applications, this won't work.

This should work, however, if you are building an application (linking with
the Runtime.o library, which has the code for initalizing global data).


>-- 
>| Louis Demers              | DREV, Defence Research Establishment,Valcartier |
>| louis@asterix.drev.dnd.ca | POBox 8800, Courcelette,Quebec, CANADA, G0A 1R0 |
>|            (131.132.48.2) | Office: (418) 844-4424       fax (418) 844-4511 |
>+---------------------------+-------------------------------------------------+

Pierre

--
--
Pierre Omidyar         {ames,apple,portal,sun,voder}!claris!pierre
Claris Corporation     pierre@claris.com  Opinions are mine and not Claris'