UC Library Extensions UnderC comes with a pocket implementation of the standard C++ libraries, wh

源代码在线查看: importing-c++-classes.txt

软件大小: 419 K
上传用户: stuoju
关键词: implementation Extensions libraries standard
下载地址: 免注册下载 普通下载 VIP

相关代码

				Any shared library that wishes to export C++ classes to UC
				must be relinked with the ucstub.cpp file. This redefines operator
				new and delete, so that both UC and the DLL use the same allocation
				strategy for objects.  In particular, an object from an imported
				class with virtual methods needs extra room for both a UC virtual
				method table (VMT) and a native virtual function table (vftable).
				
				Update: vs 1.2.0
				
				This is no longer always necessary, since UC 1.2 will choose an
				alternative strategy for associating the VMT with instances of imported
				classes. It will be somewhat slower, however. Also, you have to switch off
				global overallocation in UCW using the -O command line switch.
				
				In the case of Linux, shared libraries automatically use the overloaded 
				new & delete operators in UC, so the issue doesn't arise.
				
				To build a DLL using the MS command-line tools:
				c:\ucw\import-examples> cl -LD import5.cpp ucstub.cpp
				
				Where ucstub.cpp is no longer absolutely essential! If it wasn't there,
				then run ucw like so:
				
				c:\ucw\import-examples> ucw -O
				
				Then in your UC code have:
				 #lib import5.dll
				 #include "import5.h"
				 #lib
				
				To use GCC, either on Linux or Win32 (the Mingw release):
				
				~/stuff/ucw/import-examples$ g++ -shared import5.cpp -o import5
				
				The import1 example uses a 'fake' standard string class. Unfortunately
				UC can't cope with the real standard string (yet!) and so we have to
				use something which is similar.
				
				
							

相关资源