Always include wx/msw/winundef.h from wx/defs.h, not just once
Fix compilation/link problems due to symbols redefinitions in user code that could happen if it included some wx header first, then <windows.h> (possibly indirectly, e.g. via another third party library) and then another wx header -- in this case, the second wx header wasn't protected from <windows.h> redefinitions resulting in all the usual problems. Avoid this by always including winundef.h whenever any wx header is included, not just when wx/defs.h is included for the first time.
This commit is contained in:
parent
35620a15b6
commit
8c572c0a77
@ -10,6 +10,31 @@
|
|||||||
|
|
||||||
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
|
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
We want to avoid compilation and, even more perniciously, link errors if
|
||||||
|
the user code includes <windows.h> before include wxWidgets headers. These
|
||||||
|
error happen because <windows.h> #define's many common symbols, such as
|
||||||
|
Yield or GetClassInfo, which are also used in wxWidgets API. Including our
|
||||||
|
"cleanup" header below un-#defines them to fix this.
|
||||||
|
|
||||||
|
Moreover, notice that it is also possible for the user code to include some
|
||||||
|
wx header (this including wx/defs.h), then include <windows.h> and then
|
||||||
|
include another wx header. To avoid the problem for the second header
|
||||||
|
inclusion, we must include wx/msw/winundef.h from here always and not just
|
||||||
|
during the first inclusion, so it has to be outside of _WX_DEFS_H_ guard
|
||||||
|
check below.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/*
|
||||||
|
Test for WIN32, defined by windows.h itself, not our own __WINDOWS__,
|
||||||
|
which is not defined yet.
|
||||||
|
*/
|
||||||
|
# ifdef WIN32
|
||||||
|
# include "wx/msw/winundef.h"
|
||||||
|
# endif /* WIN32 */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WX_DEFS_H_
|
#ifndef _WX_DEFS_H_
|
||||||
#define _WX_DEFS_H_
|
#define _WX_DEFS_H_
|
||||||
|
|
||||||
@ -3294,16 +3319,6 @@ typedef const void* WXWidget;
|
|||||||
#include "wx/qt/defs.h"
|
#include "wx/qt/defs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This is required because of clashing macros in windows.h, which may be */
|
|
||||||
/* included before or after wxWidgets classes, and therefore must be */
|
|
||||||
/* disabled here before any significant wxWidgets headers are included. */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#ifdef __WINDOWS__
|
|
||||||
#include "wx/msw/winundef.h"
|
|
||||||
#endif /* __WINDOWS__ */
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/* include the feature test macros */
|
/* include the feature test macros */
|
||||||
#include "wx/features.h"
|
#include "wx/features.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user