]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/tech/tn0020.txt
syntax correction
[wxWidgets.git] / docs / tech / tn0020.txt
... / ...
CommitLineData
1 Binary Compatibility and wxWidgets
2 ==================================
30. Purpose
4----------
5
6This is broad technote covering all aspects of binary compatibility with
7wxWidgets.
8
91. Releases
10-----------
11
12General overview of releases can be found in tn0012.txt, but for
13completeness the wxWidgets release version number is as follows:
14
152.6.2
16
17Where
18
19 2 6 2
20Major Minor Release
21
22(I.E. Major.Minor.Release).
23
24All versions with EVEN minor version component (e.g. 2.4.x, 2.6.x etc.)
25are expected to be binary compatible (ODD minors are development versions
26and the compatibility constraints don't apply to them). Note that by
27preserving binary compatibility we mean BACKWARDS compatibility only,
28meaning that applications built with old wxWidgets headers should continue
29to work with new wxWidgets (shared/dynamic) libraries without the need to
30rebuild. There is no requirement to preserve compatibility in the other
31direction (i.e. make new headers compatible with old libraries) as this
32would preclude any additions whatsoever to the stable branch. But see
33also section (4).
34
35
362. What kind of changes are NOT binary compatible
37-------------------------------------------------
38
39If its still up, the KDE guide is a good reference:
40http://developer.kde.org/documentation/other/binarycompatibility.html
41
42The changes that are NOT binary compatible:
43- Adding a virtual function
44- Changing the name of a any function or variable
45- Changing the signature of a virtual function (adding a parameter,
46even a default one)
47- Changing the order of the virtual functions in a class
48["switching" them, etc.]
49- Changing access privileges of a function: some compilers (among which MSVC)
50 use the function access specifier in its mangled name. Moreover, while
51 changing a private function to public should be compatible (as the old
52 symbol can't be referenced from outside the library anyhow), changing a
53 virtual private function to public is NOT compatible because the old symbol
54 is referenced by the virtual tables in the executable code and so an old
55 program compiled with MSVC wouldn't start up with a new DLL even if it
56 doesn't use the affected symbol at all!
57- Adding a member variable
58- Changing the order of non-static member variables
59
60
613. Changes which are compatible
62-------------------------------
63
64- Adding a new class
65- Adding a new non-virtual method to an existing class
66- Overriding the implementation of an existing virtual function
67[this is considered to be backwards binary compatible until we find a
68 counter example; currently it's known to work with Apple gcc at least]
69- Anything which doesn't result in ABI change at all, e.g. adding new
70 macros, constants and, of course, private changes in the implementation
71
72
734. wxABI_VERSION and "forward" binary compatibility
74--------------------------------------------------
75
76As mentioned we do not support "forward" binary compatibility, that is the
77ability to run applications compiled with new wxWidgets headers on systems
78with old wxWidgets libraries.
79
80However, for the developers who want to ensure that their application works
81with some fixed old wxWidgets version and doesn't (inadvertently) require
82features added in later releases, we provide the macro wxABI_VERSION which
83can be defined to restrict the API exported by wxWidgets headers to that of
84a fixed old release.
85
86For this to work, all new symbols added to binary compatible releases must
87be #if'ed with wxABI_VERSION.
88
89The layout of wxABI_VERSION is as follows:
90
9120602
92
93where
94
95 2 06 02
96Major Minor Release
97
98I.E. it corresponds to the wxWidgets release in (1).
99
100An example of using wxABI_VERSION is as follows for symbols
101only in a 2.6.2 release:
102
103#if wxABI_VERSION >= 20602 /* 2.6.2+ only */
104bool Load(const wxURI& location, const wxURI& proxy);
105
106wxFileOffset GetDownloadProgress();
107wxFileOffset GetDownloadTotal();
108
109bool ShowPlayerControls(
110 wxMediaCtrlPlayerControls flags =
111 wxMEDIACTRLPLAYERCONTROLS_DEFAULT);
112
113//helpers for the wxPython people
114bool LoadURI(const wxString& fileName)
115{ return Load(wxURI(fileName)); }
116bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy)
117{ return Load(wxURI(fileName), wxURI(proxy)); }
118#endif
119
120
1215. Workarounds for adding virtual functions
122-------------------------------------------
123
124Originally the idea for adding virtual functions to binary compatible
125releases was to pad out some empty "reserved" functions and then
126rename those later when someone needed to add a virtual function.
127
128However, after there was some actual testing of the idea a lot of
129controversy erupted. Eventually we decided against the idea, and
130instead devised a new method for doing so called wxShadowObject.
131
132wxShadowObject is a class derived from wxObject that provides a means
133of adding functions and/or member variables to a class internally
134to wxWidgets. It does so by storing these in a hash map inside of
135it, looking it up when the function etc. is called. wxShadowObject
136is generally stored inside a reserved member variable.
137
138wxShadowObject resides in include/wx/clntdata.h.
139
140To use wxShadowObject, you first call AddMethod or AddField with
141the first parameter being the name of the field and/or method
142you want, and the second parameter being the value of the
143field and/or method.
144
145In the case of fields this is a void*, and in the case of method
146is a wxShadowObjectMethod which is a typedef:
147typedef int (*wxShadowObjectMethod)(void*, void*);
148
149After you add a field, you can set it via SetField with the same
150parameters as AddField, the second parameter being the value to set
151the field to. You can get the field after you call AddField
152via GetField, with the parameters as the other two field functions,
153only in the case the second parameter is the fallback
154value for the field in the case of it not being found in the
155hash map.
156
157You can call a method after you add it via InvokeMethod, which
158returns a bool indicating whether or not the method was found
159in the hash map, and has 4 parameters. The first parameter is
160the name of the method you wish to call, the second is the first
161parameter passed to the wxShadowObjectMethod, the third is the
162second parameter passed to that wxShadowObjectMethod, and the
163fourth is the return value of the wxShadowObjectMethod.
164
1656. version-script.in
166--------------------
167
168For ld/libtool we use sun-style version scripts. Basically
169anything which fits the conditions of being #if'ed via wxABI_VERSION
170needs to go here also.
171
172See 'info ld scripts version' on a GNU system, it's online here:
173http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_25.html
174
175Or see chapter 5 of the 'Linker and Libraries Guide' for Solaris, available
176online here:
177http://docsun.cites.uiuc.edu/sun_docs/C/solaris_9/SUNWdev/LLM/p1.html
178
179The file has the layout as follows:
180
181@WX_VERSION_TAG@.X
182
183Where X is the current Release as mentioned earlier, i.e. 2. This
184is following by an opening bracket "{", followed by "global:",
185followed by patterns matching added symbols, then followed by "}", and then
186the file is either followed by earlier Releases or ended by
187a @WX_VERSION_TAG@ block without the period or Release.
188
189The patterns used to specify added symbols are globbing patters and can
190contain wildcards such as '*'.
191
192For example for a new class member such as:
193 wxFont wxGenericListCtrl::GetItemFont( long item ) const;
194
195the mangled symbol might be:
196 _ZNK17wxGenericListCtrl11GetItemFontEl
197
198so a line like this could be added to version-script.in:
199 *wxGenericListCtrl*GetItemFont*;
200
201Allow for the fact that the name mangling is going to vary from compiler to
202complier.
203
204When adding a class you can match all the symbols it adds with a single
205pattern, so long as that pattern is not likely to also match other symbols.
206For example for wxLogBuffer a line like this:
207 *wxLogBuffer*;
208
209
2107. Checking the version information in libraries and programs
211-------------------------------------------------------------
212
213On Sun there is a tool for this, see pvs(1). On GNU you can use objdump, below
214are some examples.
215
216To see what versions of each library a program (or library) depends on:
217
218$ objdump -p widgets | sed -ne '/Version References/,/^$/p'
219Version References:
220 required from libgcc_s.so.1:
221 0x0b792650 0x00 10 GCC_3.0
222 required from libwx_based-2.6.so.0:
223 0x0cca2546 0x00 07 WXD_2.6
224 required from libstdc++.so.6:
225 0x056bafd3 0x00 09 CXXABI_1.3
226 0x08922974 0x00 06 GLIBCXX_3.4
227 required from libwx_gtk2d_core-2.6.so.0:
228 0x0a2545d2 0x00 08 WXD_2.6.2
229 0x0cca2546 0x00 05 WXD_2.6
230 required from libc.so.6:
231 0x09691a75 0x00 04 GLIBC_2.2.5
232
233To see what WXD_2.6.2 symbols a program uses:
234
235$ objdump -T widgets | grep 'WXD_2\.6\.2'
2360000000000000000 g DO *ABS* 0000000000000000 WXD_2.6.2 WXD_2.6.2
23700000000004126d8 DF *UND* 0000000000000177 WXD_2.6.2 _ZN19wxTopLevelWindowGTK20RequestUserAttentionEi
238
239To see what WXD_2.6.2 symbols a library defines:
240
241$ objdump -T libwx_based-2.6.so | grep 'WXD_2\.6\.2' | grep -v 'UND\|ABS'
2420000000000259a10 w DO .data 0000000000000018 WXD_2.6.2 _ZTI19wxMessageOutputBest
24300000000002599e0 w DO .data 0000000000000028 WXD_2.6.2 _ZTV19wxMessageOutputBest
244000000000010a98e w DF .text 000000000000003e WXD_2.6.2 _ZN19wxMessageOutputBestD0Ev
2450000000000114efb w DO .rodata 000000000000000e WXD_2.6.2 _ZTS11wxLogBuffer
2460000000000255590 w DO .data 0000000000000018 WXD_2.6.2 _ZTI11wxLogBuffer
247000000000011b550 w DO .rodata 0000000000000016 WXD_2.6.2 _ZTS19wxMessageOutputBest
24800000000000bfcc8 g DF .text 00000000000000dd WXD_2.6.2 _ZN11wxLogBuffer5DoLogEmPKcl
249000000000010a3a6 g DF .text 0000000000000153 WXD_2.6.2 _ZN19wxMessageOutputBest6PrintfEPKcz
25000000000000c0b22 w DF .text 000000000000004b WXD_2.6.2 _ZN11wxLogBufferD0Ev
25100000000000bfc3e g DF .text 0000000000000089 WXD_2.6.2 _ZN11wxLogBuffer5FlushEv
25200000000000c0ad6 w DF .text 000000000000004b WXD_2.6.2 _ZN11wxLogBufferD1Ev
25300000000000b1130 w DF .text 0000000000000036 WXD_2.6.2 _ZN11wxLogBufferC1Ev
25400000000000c095c w DF .text 0000000000000029 WXD_2.6.2 _ZN19wxMessageOutputBestC1Ev
25500000000000c08e8 w DF .text 000000000000003e WXD_2.6.2 _ZN19wxMessageOutputBestD1Ev
25600000000002554c0 w DO .data 0000000000000038 WXD_2.6.2 _ZTV11wxLogBuffer
25700000000000bfda6 g DF .text 0000000000000036 WXD_2.6.2 _ZN11wxLogBuffer11DoLogStringEPKcl
25800000000000abe10 g DF .text 0000000000000088 WXD_2.6.2 _ZN14wxZipFSHandler7CleanupEv
259
260
2618. Testing binary compatibility between releases
262------------------------------------------------
263
264An easy way of testing binary compatibility is just to build wxWidgets
265in dll/dynamic library mode and then switch out the current library
266in question with an earlier stable version of the library, then running
267the application in question again. If it runs OK then there is usually
268binary compatibility between those releases.
269
270You can also break into your debugger or whatever program you want
271to use and check the memory layout of the class. If it is the same
272then it is binary compatible.
273
274Also remember to look at http://www.wxwidgets.org/bincompat.html page which
275summarizes the results of testing of all the samples built against old
276libraries headers with the new library binaries under Unix.
277
278
279=== EOF ===
280
281Author: RN
282Version: $Id$