importing-c++-classes.txt.svn-base

来自「这是一段游戏修改工具的源代码.ring3功能由dephi开发,驱动是C开发.希望」· SVN-BASE 代码 · 共 40 行

SVN-BASE
40
字号
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.


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?