-
Notifications
You must be signed in to change notification settings - Fork 280
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
Export classes and functions from library for Windows & Linux #244
Comments
Following up on my question here... I'm still not persuaded that exporting classes is better that exporting well designed functions.
Of course there would need to be a similar function that returned |
May I add my two cents, please? I don't know how/is the version compatibility check is done in Windows world nowadays and was it ever implemented in MS C++ compiler system-wide. so to say (last time I coded something for Windows in the beginning of zeroes). Nevertheless, I don't see a problem to implement such a check: there is a number of ways to call a function before As for defining wrappers - it would only increase code maintenance difficulty: every time you change any method declaration to be exported you have to change the interface function. So, this is really unnecessary level of indirection and an additional source of possible bugs. |
Well I'm certainly motivated to avoid code maintenance as much as possible. And part of that is keeping the code as simple as possible. Anyhow, I'm not against exporting classes in principle, I'm just hoping for a dll/so solution that works well on all platforms. |
When Clipper has a permissive license and compiles to a reasonably small binary, what exactly is the use case for a Clipper.dll on Windows? |
The C implementation is the fastest. You could convert this into a DLL. Delphi people can then just use these dll and take advantage of the speed. |
But Delphi surely can't import C++ classes? So for that use case, there should be a plain C API, right? |
Yep! |
And why I'm still (very slightly) leaning toward function wrappers instead of exposing classes. |
Yes, this changes the picture. |
I've just added a new |
I can't duplicate this. Are you using the latest commit?
|
Yes, I do |
OK, I missed that bit. Edit: cdecl; |
Fix just uploaded. |
Firstly, the performance test I've coded in the sample apps intentionally creates multiple intersections at the same locations as a kind of stress test of the clipping algorithm. And this also significantly slows clipping. This is important because it's not just the number of edges that affects timing, but the size of the random polygons too. Larger polygons will have fewer co-located intersections so clipping will be faster. Perhaps surprisingly ClipperD performance will usually appear to be much faster than Clipper64, but this is simply because ClipperD obects by default scale their paths *100. Consequently their polygons are much bigger (during clipping) and will have fewer co-located intersections. IOW, make sure you're comparing Clipper64 with Clipper64 (or comparing Clipper64 with ClipperD without scaling) and make sure the random polygons are generated into the same regions. |
Okay, understood, of course I have to take that into account. |
The DLL exporting of classes and methods on Windows requires them to be exported using:
The above should be in a header file on its own and included as needed.
With classes defined:
When building the define CLIPPER2_DLL_EXPORT is declared. When linking to a library the define is not set.
On Linux the classes and methods will also be exported correctly when the option
-fvisibility=hidden
is used when creating a shared library.Also see #169
The text was updated successfully, but these errors were encountered: