forcelnk.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/html/forcelnk.h
  3. // Purpose: macros which force the linker to link apparently unused code
  4. // Author: Vaclav Slavik
  5. // Copyright: (c) Vaclav Slavik
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. /*
  9. DESCRPITON:
  10. mod_*.cpp files contain handlers for tags. These files are modules - they contain
  11. one wxTagModule class and it's OnInit() method is called from wxApp's init method.
  12. The module is called even if you only link it into the executable, so everything
  13. seems wonderful.
  14. The problem is that we have these modules in LIBRARY and mod_*.cpp files contain
  15. no method nor class which is known out of the module. So the linker won't
  16. link these .o/.obj files into executable because it detected that it is not used
  17. by the program.
  18. To workaround this I introduced set of macros FORCE_LINK_ME and FORCE_LINK. These
  19. macros are generic and are not limited to mod_*.cpp files. You may find them quite
  20. useful somewhere else...
  21. How to use them:
  22. let's suppose you want to always link file foo.cpp and that you have module
  23. always.cpp that is certainly always linked (e.g. the one with main() function
  24. or htmlwin.cpp in wxHtml library).
  25. Place FORCE_LINK_ME(foo) somewhere in foo.cpp and FORCE_LINK(foo) somewhere
  26. in always.cpp
  27. See mod_*.cpp and htmlwin.cpp for example :-)
  28. */
  29. #ifndef _WX_FORCELNK_H_
  30. #define _WX_FORCELNK_H_
  31. #include "wx/link.h"
  32. // compatibility defines
  33. #define FORCE_LINK wxFORCE_LINK_MODULE
  34. #define FORCE_LINK_ME wxFORCE_LINK_THIS_MODULE
  35. #define FORCE_WXHTML_MODULES() \
  36. FORCE_LINK(m_layout) \
  37. FORCE_LINK(m_fonts) \
  38. FORCE_LINK(m_image) \
  39. FORCE_LINK(m_list) \
  40. FORCE_LINK(m_dflist) \
  41. FORCE_LINK(m_pre) \
  42. FORCE_LINK(m_hline) \
  43. FORCE_LINK(m_links) \
  44. FORCE_LINK(m_tables) \
  45. FORCE_LINK(m_span) \
  46. FORCE_LINK(m_style)
  47. #endif // _WX_FORCELNK_H_