Make OfxExport export a symbol on GCC and Clang, and use it in the examples - #274
Merged
Merged
Conversation
…amples
OfxExport expanded to __declspec(dllexport) on Windows and to plain
extern everywhere else, so on macOS and Linux it did nothing. A plugin
built with hidden visibility, as the CMake and pcons builds do, exported
no entry points through it, and every example carried its own eight-line
EXPORT block to add the visibility attribute. OfxExport now adds
__attribute__((visibility("default"))) under GCC and Clang, which is what
the header's own OfxGetPlugin and OfxGetNumberOfPlugins declarations need.
The examples drop their EXPORT macros and use OfxExport directly. Each
still exports exactly OfxGetPlugin and OfxGetNumberOfPlugins when built
with -fvisibility=hidden.
Assisted-by: Claude Code / Claude Fable 5.1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
garyo
requested review from
Guido-assim,
fxtech,
john-paulsmith and
revisionfx
September 22, 2026 19:10
garyo
marked this pull request as ready for review
September 22, 2026 19:12
Guido-assim
reviewed
Sep 23, 2026
Contributor
There was a problem hiding this comment.
The function declarations for OfxGetPlugin, OfxGetNumberOfPlugins and OfxSetHost in ofxCore.h already have the OfxExport specifier, I don't think it is needed to have it again with the definitions in the cpp files.
The definition of OfxSetHost in colourspace.cpp seems to be missing the host argument.
…Host With the visibility attribute on the entry-point declarations in ofxCore.h, a plugin's definitions inherit it: built with hidden visibility, bare definitions of OfxGetPlugin, OfxGetNumberOfPlugins and OfxSetHost are exported and nothing else is. The examples now define them with no specifier, which is the pattern plugin authors should copy. The ColourSpace example's OfxSetHost took no parameter. In C++ that is a separate overload with C++ linkage, exported under a mangled name, so no host ever found or called it; it now takes the const OfxHost * the header declares. The release note no longer mentions a pcons build, which main does not have. Assisted-by: Claude Code / Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
Contributor
Author
|
Good catch on both, Guido. Updated the PR to remove the decls in the examples. Also I fixed the colourspace example (that was preventing OfxSetHost from getting called on that example altogether, since it's a different function, not even "export "C""). |
The Programming Guide's five example plugins each defined the same EXPORT macro as the examples did, and marked their entry points with it. The definitions now inherit OfxExport from the declarations in ofxCore.h, which also matches the snippets the guide shows, which never had a specifier. Each still builds warning-free with hidden visibility and exports exactly OfxGetPlugin and OfxGetNumberOfPlugins. Assisted-by: Claude Code / Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
OfxExportexpanded to__declspec(dllexport)on Windows and to plainexterneverywhere else, so on macOS and Linux it did nothing. A plugin built with hidden visibility (as the CMake build does, viaCXX_VISIBILITY_PRESET hidden) exported no entry points through it, and every example carried its own eight-lineEXPORTblock to supply the visibility attribute.OfxExportnow adds__attribute__((visibility("default")))under GCC and Clang. The entry pointsOfxGetPlugin,OfxGetNumberOfPluginsandOfxSetHostare declared with it inofxCore.h, and a plugin's definitions inherit the attribute from those declarations, so they are exported with no specifier of their own.Documentation/sources/Guide/Code/, drop theirEXPORTmacros and define the entry points with no specifier, the pattern plugin authors can copy (18 files, net -122 lines). That also matches the guide's own snippets, which never showed a specifier.Support/Librarykeeps its ownEXPORT/LOCALpair for now, since it also usesLOCAL.OfxSetHosttook no parameter. In C++ that made it a separate overload with C++ linkage, exported under a mangled name (__Z10OfxSetHostv), so no host ever found or called it. It now takes theconst OfxHost *the header declares.Compatibility
OfxExportor their own visibility attribute on their definitions keep working: the attribute is simply repeated, which compilers accept silently.Test plan
OfxGetPluginandOfxGetNumberOfPlugins, plusOfxSetHostfor ColourSpace, on macOS (checked withnm -gU). Overlay, which is not in the CMake plugin list, and the five guide examples checked the same way by hand; all build warning-free.ofxCore.hexport nothing under-fvisibility=hidden; against this branch they export exactly those three, in both C and C++, and an undeclared helper stays hidden.Assisted-by: Claude Code / Claude Fable 5.1, Claude Opus 5.5