]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/backwardcompat.tex
replaced deprecated wxMULTIPLE with wxFD_MULTIPLE
[wxWidgets.git] / docs / latex / wx / backwardcompat.tex
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: backwardcompat.tex
3 %% Purpose: Explains how much and what kind of backward compatibility users
4 %% can expect
5 %% Author: M.J.Wetherell
6 %% RCS-ID: $Id$
7 %% Copyright: 2005 M.J.Wetherell
8 %% License: wxWindows license
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11 \section{Backward compatibility}\label{backwardcompatibility}
12
13 Many of the GUIs and platforms supported by wxWidgets are continuously
14 evolving, and some of the new platforms wxWidgets now supports were quite
15 unimaginable even a few years ago. In this environment wxWidgets must also
16 evolve in order to support these new features and platforms.
17
18 However the goal of wxWidgets is not only to provide a consistent
19 programming interface across many platforms, but also to provide an
20 interface that is reasonably stable over time, to help protect its users
21 from some of the uncertainty of the future.
22
23 \subsection{The version numbering scheme}\label{versionnumbering}
24
25 wxWidgets version numbers can have up to four components, with trailing
26 zeros sometimes omitted:
27
28 \begin{verbatim}
29 major.minor.release.sub-release
30 \end{verbatim}
31
32 A {\em stable} release of wxWidgets will have an even number for {\tt
33 minor}, e.g. {\tt 2.6.0}.
34
35 Stable, in this context, means that the API is not changing. In truth, some
36 changes are permitted, but only those that are backward compatible. For
37 example, you can expect later {\tt 2.6.x.x} releases, such as {\tt 2.6.1}
38 and {\tt 2.6.2} to be backward compatible with their predecessor.
39
40 When it becomes necessary to make changes which are not wholly backward
41 compatible, the stable branch is forked, creating a new {\em development}
42 branch of wxWidgets. This development branch will have an odd number
43 for {\tt minor}, for example {\tt 2.7.x.x}. Releases from this branch are
44 known as {\em development snapshots}.
45
46 The stable branch and the development branch will then be developed in
47 parallel for some time. When it is no longer useful to continue developing
48 the stable branch, the development branch is renamed and becomes a new
49 stable branch, for example {\tt 2.8.0}. And the process begins again.
50
51 This is how the tension between keeping the interface stable, and allowing
52 the library to evolve is managed.
53
54 You can expect the versions with the same major and {\em even} minor
55 version number to be compatible, but between minor versions there will be
56 incompatibilities. Compatibility is not broken gratuitously however, so
57 many applications will require no changes or only small changes to work
58 with the new version.
59
60 \subsection{Source level compatibility}\label{sourcecompatibility}
61
62 Later releases from a stable branch are backward compatible with earlier
63 releases from the same branch at the {\em source} level.
64
65 This means that, for example, if you develop your application using
66 wxWidgets {\tt 2.6.0} then it should also compile fine with all later {\tt
67 2.6.x} versions. The converse is also true providing you avoid any new
68 features not present in the earlier version. For example if you develop
69 using {\tt 2.6.1} your program will compile fine with wxWidgets {\tt 2.6.0}
70 providing you don't use any {\tt 2.6.1} specific features.
71
72 For some platforms binary compatibility is also supported, see 'Library
73 binary compatibility' below.
74
75 Between minor versions, for example between {\tt 2.2.x}, {\tt 2.4.x} and {\tt
76 2.6.x}, there will be some incompatibilities. Wherever possible the old way
77 of doing something is kept alongside the new for a time wrapped inside:
78
79 \begin{verbatim}
80 #if WXWIN_COMPATIBILITY_2_4
81 /* deprecated feature */
82 ...
83 #endif
84 \end{verbatim}
85
86 By default the {\tt WXWIN\_COMPATIBILITY{\it \_X\_X}} macro is set
87 to 1 for the previous stable branch, for example
88 in {\tt 2.6.x} {\tt WXWIN\_COMPATIBILITY\_2\_4 = 1}. For the next earlier
89 stable branch the default is 0, so {\tt WXWIN\_COMPATIBILITY\_2\_2 = 0}
90 for {\tt 2.6.x}. Earlier than that, obsolete features are removed.
91
92 These macros can be changed in {\tt setup.h}. Or on UNIX-like systems you can
93 set them using the {\tt --disable-compat24} and {\tt --enable-compat22}
94 options to {\tt configure}.
95
96 They can be useful in two ways:
97
98 \begin{enumerate}
99 \item Changing {\tt WXWIN\_COMPATIBILITY\_2\_4} to 0 can be useful to
100 find uses of deprecated features in your program.
101 \item Changing {\tt WXWIN\_COMPATIBILITY\_2\_2} to 1 can be useful to
102 compile a program developed using {\tt 2.2.x} that no longer compiles
103 with {\tt 2.6.x}.
104 \end{enumerate}
105
106 A program requiring one of these macros to be 1 will become
107 incompatible with some future version of wxWidgets, and you should consider
108 updating it.
109
110 \subsection{Library binary compatibility}\label{libbincompatibility}
111
112 For some platforms, releases from a stable branch are not only source level
113 compatible but can also be {\em binary compatible}.
114
115 Binary compatibility makes it possible to get the maximum benefit from
116 using shared libraries, also known as dynamic link libraries (DLLs) on
117 Windows or dynamic shared libraries on OS X.
118
119 For example, suppose several applications are installed on a system requiring
120 wxWidgets {\tt 2.6.0}, {\tt 2.6.1} and {\tt 2.6.2}. Since {\tt 2.6.2} is
121 backward compatible with the earlier versions, it should be enough to
122 install just wxWidgets {\tt 2.6.2} shared libraries, and all the applications
123 should be able to use them. If binary compatibility is not supported, then all
124 the required versions {\tt 2.6.0}, {\tt 2.6.1} and {\tt 2.6.2} must be
125 installed side by side.
126
127 Achieving this, without the user being required to have the source code
128 and recompile everything, places many extra constraints on the changes
129 that can be made within the stable branch. So it is not supported for all
130 platforms, and not for all versions of wxWidgets. To date it has mainly
131 been supported by wxGTK for UNIX-like platforms.
132
133 Another practical consideration is that for binary compatibility to work,
134 all the applications and libraries must have been compiled with compilers
135 that are capable of producing compatible code; that is, they must use the
136 same ABI (Application Binary Interface). Unfortunately most different C++
137 compilers do not produce code compatible with each other, and often even
138 different versions of the same compiler are not compatible.
139
140 \subsection{Application binary compatibility}\label{appbincompatibility}
141
142 The most important aspect of binary compatibility is that applications
143 compiled with one version of wxWidgets, e.g. {\tt 2.6.1}, continue to work
144 with shared libraries of a later binary compatible version, for example {\tt
145 2.6.2}.
146
147 The converse can also be useful however. That is, it can be useful for a
148 developer using a later version, e.g. {\tt 2.6.2} to be able to create binary
149 application packages that will work with all binary compatible versions of
150 the shared library starting with, for example {\tt 2.6.0}.
151
152 To do this the developer must, of course, avoid any features not available
153 in the earlier versions. However this is not necessarily enough; in some
154 cases an application compiled with a later version may depend on it even
155 though the same code would compile fine against an earlier version.
156 % thinks: a situation we should try to avoid.
157
158 To help with this, a preprocessor symbol {\tt wxABI\_VERSION} can be defined
159 during the compilation of the application (this would usually be done in the
160 application's makefile or project settings). It should be set to the lowest
161 version that is being targeted, as a number with two decimal digits for each
162 component, for example {\tt wxABI\_VERSION=20600} for {\tt 2.6.0}.
163
164 Setting {\tt wxABI\_VERSION} should prevent the application from implicitly
165 depending on a later version of wxWidgets, and also disables any new features
166 in the API, giving a compile time check that the source is compatible with
167 the versions of wxWidgets being targeted.
168
169 Uses of {\tt wxABI\_VERSION} are stripped out of the wxWidgets sources when
170 each new development branch is created. Therefore it is only useful to help
171 achieve compatibility with earlier versions with the same major
172 and {\em even} minor version numbers. It won't, for example, help you write
173 code compatible with {\tt 2.4.x} using wxWidgets {\tt 2.6.x}.