dispatch: split DISPATCH_EXPORT
and prepare for static linking
#872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change accomplishes two items:
DISPATCH_EXTERN
macro to decorate withextern
orextern "C"
based on the compilation mode (C vs C++).dispatch_STATIC
) that allows building with libdispatch for static linking. The default remains dynamic linking.The motivation for
DISPATCH_EXTERN
is primarily being able to concisely defineDISPATCH_EXPORT
. This follows the naming scheme that most other Apple frameworks use (e.g. UIKit, Foundation, etc).The change to introduce support for static linking is motivated by Windows. With the gradual roll out of static linking of the runtime, it would be convenient to be able to statically link dispatch into a fully sealed Swift program. Doing so requires building libdispatch without the
__declspec(dllexport)
and__declspec(dllimport)
attributes on Windows. Similarly, it would be unfortunate to have dispatch's ABI be subsumed by a client library and have it participate in dynamic linking.The user is responsible for defining
dispatch_STATIC
when using a static copy of libdispatch. This allows the default to remain dynamic linking (which is the preferred style on Darwin and Windows).