]>
Commit | Line | Data |
---|---|---|
5526e819 | 1 | ///////////////////////////////////////////////////////////////////////////// |
69941f05 | 2 | // Name: forcelnk.h |
5526e819 VS |
3 | // Purpose: see bellow |
4 | // Author: Vaclav Slavik | |
69941f05 VS |
5 | // RCS-ID: $Id$ |
6 | // Copyright: (c) Vaclav Slavik | |
65571936 | 7 | // Licence: wxWindows licence |
5526e819 VS |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | /* | |
11 | ||
12 | DESCRPITON: | |
13 | ||
14 | mod_*.cpp files contain handlers for tags. These files are modules - they contain | |
15 | one wxTagModule class and it's OnInit() method is called from wxApp's init method. | |
16 | The module is called even if you only link it into the executable, so everything | |
17 | seems wonderful. | |
18 | ||
19 | The problem is that we have these modules in LIBRARY and mod_*.cpp files contain | |
20 | no method nor class which is known out of the module. So the linker won't | |
21 | link these .o/.obj files into executable because it detected that it is not used | |
22 | by the program. | |
23 | ||
24 | To workaround this I introduced set of macros FORCE_LINK_ME and FORCE_LINK. These | |
25 | macros are generic and are not limited to mod_*.cpp files. You may find them quite | |
26 | useful somewhere else... | |
27 | ||
28 | How to use them: | |
29 | let's suppose you want to always link file foo.cpp and that you have module | |
30 | always.cpp that is certainly always linked (e.g. the one with main() function | |
31 | or htmlwin.cpp in wxHtml library). | |
32 | ||
33 | Place FORCE_LINK_ME(foo) somewhere in foo.cpp and FORCE_LINK(foo) somewhere | |
34 | in always.cpp | |
35 | See mod_*.cpp and htmlwin.cpp for example :-) | |
36 | ||
37 | */ | |
38 | ||
39 | ||
69941f05 VS |
40 | #ifndef _WX_FORCELNK_H_ |
41 | #define _WX_FORCELNK_H_ | |
5526e819 VS |
42 | |
43 | ||
44 | ||
45 | // This must be part of the module you want to force: | |
46 | #define FORCE_LINK_ME(module_name) \ | |
9ea7b86f VS |
47 | int _wx_link_dummy_func_##module_name (); \ |
48 | int _wx_link_dummy_func_##module_name () \ | |
5526e819 VS |
49 | { \ |
50 | return 1; \ | |
51 | } | |
52 | ||
53 | ||
54 | // And this must be somewhere where it certainly will be linked: | |
55 | #define FORCE_LINK(module_name) \ | |
9ea7b86f VS |
56 | extern int _wx_link_dummy_func_##module_name (); \ |
57 | static int _wx_link_dummy_var_##module_name = \ | |
58 | _wx_link_dummy_func_##module_name (); | |
5526e819 | 59 | |
0cecad31 VS |
60 | #define FORCE_WXHTML_MODULES() \ |
61 | FORCE_LINK(m_layout) \ | |
62 | FORCE_LINK(m_fonts) \ | |
63 | FORCE_LINK(m_image) \ | |
64 | FORCE_LINK(m_list) \ | |
65 | FORCE_LINK(m_dflist) \ | |
66 | FORCE_LINK(m_pre) \ | |
67 | FORCE_LINK(m_hline) \ | |
68 | FORCE_LINK(m_links) \ | |
69 | FORCE_LINK(m_tables) \ | |
c44fdc94 | 70 | FORCE_LINK(m_style) |
0cecad31 | 71 | |
5526e819 | 72 | |
69941f05 | 73 | #endif // _WX_FORCELNK_H_ |