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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial C API for FFI #663
Initial C API for FFI #663
Changes from 1 commit
6becbe5
eb2e094
d345a2e
47944fe
7fb1ff5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GCC and Clang do need an EXPORT_API definition since GCC v4
It is strongly recommended not to export all functions, especially for a C-API as it greatly reduces the chance of name collisions and speeds up the dylib/so loader.
The draco C-API so/dylib should be compiled with the flag -fvisibility=hidden, and the following added for GCC and clang compilers:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little bit tricky to implement with the current approach of building the C-API as part of the "core" library, but I do agree it should happen.
The problem I'm facing if only the C-API is exported then the executables (
draco_decoder
anddraco_encoder
) nor the tests can be correctly linked as those depend on the C++ API.I'm starting to lean towards having a separate library for the C-API, as the CMake orchestration would be much more easy to manage and the
DRACO_C_API
will be orthogonal to other features. What do you think @RichardTea?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's reasonable to pick an API for your shared libraries at configure time, as I'm reasonably sure that most consumers of the C-API will not want to use the C++ version of the dynamic library anyway.
The whole point of a C-API is to ensure a consistent ABI, so exposing all the C++-mangled stuff could rather complicate things on some compilers.
If it's difficult to build all four at the same time then I think draco_encoder, draco_decoder and the C-API shared lib could all consume the same C++ static library "privately" to achieve the goal of hiding all the internal symbols - IIRC, symbols aren't ever truly private in a static library so that should still work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've finally moved the C-API to its own library called
cdraco.[dll/lib/so/a/...]
, gated by theDRACO_C_API
flag. This library is self contained and the dynamic version just exports the C-API, all the C++ stuff is hidden.