Eliminate public header file's dependency on CoreServices.h

wx public headers are not supposed to include platform-specific headers
defining many macros that can conflict with the identifiers defined in
the application code. In this particular case, including CoreServices.h
ultimately #included AssertMacros.h, which by default on older SDKs
(<10.12) introduces various macros whose names very easily conflict with
user code.

For example, if you #included <wx/fswatcher.h> in your own code, and
your code happened to contain a symbol called 'check', or 'verify',
compilation failed.

Fix this by using pImpl idiom to move the variable requiring a type
defined in the SDK header into the source file.

Closes https://github.com/wxWidgets/wxWidgets/pull/1666
This commit is contained in:
Lauri Nurmi
2019-11-29 22:54:20 +02:00
committed by Vadim Zeitlin
parent 69da383e96
commit e6945aeedc
2 changed files with 27 additions and 19 deletions

View File

@@ -15,11 +15,8 @@
#if wxUSE_FSWATCHER
#include <CoreServices/CoreServices.h>
#include "wx/unix/fswatcher_kqueue.h"
WX_DECLARE_STRING_HASH_MAP(FSEventStreamRef, FSEventStreamRefMap);
/*
The FSEvents watcher uses the newer FSEvents service
that is available in OS X, the service allows for
@@ -78,8 +75,10 @@ public:
private:
// map of path => FSEventStreamRef
FSEventStreamRefMap m_streams;
// use the pImpl idiom to eliminate this header's dependency
// on CoreServices.h (and ultimately AssertMacros.h)
struct PrivateData;
PrivateData *m_pImpl;
};