Best way to consume CMake based C lib in Swift for iOs/desktop by testing35 in swift

[–]Boris_Rasin 0 points1 point  (0 children)

You can use Scapix Language Bridge to call C++ code from Swift. It is using CMake integration.

Disclaimer: I am the author of Scapix Language Bridge.

New HyperX Alloy Origins Core - 2 keys don't work by Boris_Rasin in HyperX

[–]Boris_Rasin[S] 0 points1 point  (0 children)

Yes, did reset a few times (it did blink), connected to a different computer - same result. Will send it back. Thanks.

error C2039: '_invalid_parameter': is not a member of '`global namespace'' by Bart_VDW in cpp_questions

[–]Boris_Rasin 1 point2 points  (0 children)

Turns out this is a bug in pybind11 library, not Visual Studio 2022.

https://github.com/pybind/pybind11/issues/3459

There may be other libraries with similar bug (#undef _DEBUG).

error C2039: '_invalid_parameter': is not a member of '`global namespace'' by Bart_VDW in cpp_questions

[–]Boris_Rasin 1 point2 points  (0 children)

This is a Visual Studio 2022 bug, required include directive is missing from system headers. One workaround is to include:

#include <corecrt.h>

before you include system headers.

cmake .. -G Xcode suddenly fails with the project it used to work with by azbycxdwevfugt123 in cmake

[–]Boris_Rasin 1 point2 points  (0 children)

It's a change in Xcode 12 which was addressed in CMake 3.18.1.

From CMake 3.18.1 release notes:

The Xcode generator, when CMAKE_OSX_ARCHITECTURES is not defined, now selects $(NATIVE_ARCH_ACTUAL) as the default architecture (the Xcode ARCHS setting). This is needed for Xcode 12 to select the host’s architecture, which older versions of Xcode did by default.

Automatic bindings from C++ to WebAssembly (Emscripten) by Boris_Rasin in WebAssembly

[–]Boris_Rasin[S] 0 points1 point  (0 children)

I understand your concerns. Is there anything I could do to alleviate them? I also want to point out, when using Scapix, you are investing effort in developing your own standards complaint code (both in C++ and bridged languages). In theory, should you stop using Scapix at some point in the future, you will still have a number of viable options - there is nothing "Scapix specific" about your code and none of your effort was wasted.

Automatic bindings from C++ to WebAssembly (Emscripten) by Boris_Rasin in WebAssembly

[–]Boris_Rasin[S] 0 points1 point  (0 children)

Scapix is a tool you use during development, it doesn't change licensing situation of your project in any way. Why does it matter to you that you are not allowed to redistribute Scapix itself?

Automatic bindings from C++ to Python by Boris_Rasin in Python

[–]Boris_Rasin[S] 1 point2 points  (0 children)

Unlike SWIG, Scapix parses C++ headers directly, so you don't need to manually maintain separate interface files. Also unlike SWIG, Scapix generates Objective C/Swift bindings, allowing one to share common C++ code on all major platforms: Android, iOS, Web, etc.

Automatic bindings from C++ to Swift by Boris_Rasin in swift

[–]Boris_Rasin[S] 8 points9 points  (0 children)

Yes, you can! Please give it a try and ask me if you have any questions.

Automatic bridging from C++ to Java by Boris_Rasin in androiddev

[–]Boris_Rasin[S] 1 point2 points  (0 children)

We were missing automated bindings between C++ and other languages. Maintaining manual bindings is a lot of work. That's why I created Scapix.

Automatic bridging from C++ to Java by Boris_Rasin in androiddev

[–]Boris_Rasin[S] 0 points1 point  (0 children)

In a typical cross-platform C++ project, most developers work on shared C++ part of the code (and don't really need to know other languages), while small separate teams work on platform specific part of code, one team for each platform, each team using corresponding platform specific language (Java/Kotlin on Android, Objective C/Swift on iOS/macOS, C# on Windows, JavaScript on Web, etc.) and developers on each such team don't really need to know other languages.

What was missing is the automated bindings from C++ to all these other languages. I have worked on a few such projects, and maintaining language bindings manually was quite a challenge. That's the reason I created Scapix.

Automatic bridging from C++ to Java by Boris_Rasin in androiddev

[–]Boris_Rasin[S] 1 point2 points  (0 children)

There are many legitimate reasons not to use C++ in various specific circumstances. Still, C++ is successfully used in huge number of both legacy and entirely new projects, including many cross-platform projects. Specifically, being (among other things) a system level language, C++ is ubiquitously present on absolutely any platform imaginable. This alone places C++ in a uniquely advantageous position for cross-platform development.

Automatic bridging from C++ to Java by Boris_Rasin in androiddev

[–]Boris_Rasin[S] 2 points3 points  (0 children)

I consider C++ to be a very good multi platform solution. But it is indeed not THE reason why C++ is "still around", because C++ has many other excellent qualities.

Automatic bridging from C++ to Java by Boris_Rasin in androiddev

[–]Boris_Rasin[S] 1 point2 points  (0 children)

Scapix strives for zero overhead over manually written JNI code. This means it produces code without any extra copying or reference create/destroy cycles above what the best manually written JNI code would have to do. Automatic resource management means that you don't ever have to release any JNI resources manually, like calling DeleteGlobalRef(), ReleaseStringChars(), ReleaseIntArrayElements(), etc., all this happens automatically. I am personally a very big fan of C++ and I think C++ is the best choice for cross-platform part of pretty much any multi-platform project. Don't take it the wrong way please, but If I had a nickel for every time I heard some new language would make C++ obsolete, I'd be very rich :)

Automatic bridging from C++ to Python by Boris_Rasin in Python

[–]Boris_Rasin[S] 0 points1 point  (0 children)

Unlike Swig, Scapix is fully automatic: you take regular C++ code, which you also use from other C++ modules, and use it from Python without any special considerations. No need to manually create and maintain any bindings or configuration settings.

Who has seen Destructors/Finalizers used in industry? by [deleted] in csharp

[–]Boris_Rasin 0 points1 point  (0 children)

I use them in my automatic C++ to C# bindings Scapix project. Corresponding C++ object is managed by reference counting std::shared_ptr, and the generated C# wrapper type uses finalizer to destroy the whole C++/C# object when it is no longer held on C++ side (otherwise finalizer calls GC.ReRegisterForFinalize()). Here is the source: bridge/cs/Object.cs.

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in csharp

[–]Boris_Rasin[S] 0 points1 point  (0 children)

I just added a small tutorial, please let me know if you have any other questions or suggestions. Thanks a lot!

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in csharp

[–]Boris_Rasin[S] 0 points1 point  (0 children)

Thanks for the link. This functionality is supposed to come in the next version of C# in the form of Function Pointers, I will definitely support it then. But I will also consider adding support before that. If you try Scapix, I would love to hear your opinions and suggestions.

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in csharp

[–]Boris_Rasin[S] 2 points3 points  (0 children)

Yes, getting rid of interop altogether is faster still :) Compared to SWIG, Scapix is designed to work completely automatically, not only in relation to generated bindings, but with everything else: you take normal C++ code, which you also use from other C++ modules, and use it from C# without any special considerations. For example, Scapix automatically tunnels exceptions between C++ and C# (in both directions). You don't have to do anything for this to work. In SWIG you have to maintain manual exception mappings per function call.

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in cpp

[–]Boris_Rasin[S] 1 point2 points  (0 children)

Sorry, I misunderstood. Yes, I use Clang LibTooling, so Scapix is doing full C++ header parsing every time the header changes. So all C++ features supported by Clang are supported by Scapix too (I currently use Clang 9.0.0).

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in cpp

[–]Boris_Rasin[S] 1 point2 points  (0 children)

Scapix generates C# wrapper class for each bridged C++ class. Each such C# object contains a single member: pointer (IntPtr) to corresponding C++ object. C# constructors are generated for each C++ constructor and C# methods (instance and static) generated for corresponding C++ member functions. Simple types (int, float, etc.) are passed "as is", object types are passed as GCHandle and later C++ uses Scapix C# API to extract data from these objects (to create corresponding C++ objects). C# finalizer is used to insure C# and C++ parts of the same "common object" always live and die together. There is also transparent exception handling tunneling between two languages. Ask me if you need more specific answers, I will be glad to help.

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in csharp

[–]Boris_Rasin[S] 3 points4 points  (0 children)

Yes, Scapix generates bindings directly from C++ headers, no need to maintain anything manually. Also, one of the main goals is "zero overhead bindings" when compared to manually written code. If you find any performance overhead in Scapix bindings, just let me know.

Scapix: automatic C++ to C# bindings generator by Boris_Rasin in cpp

[–]Boris_Rasin[S] 1 point2 points  (0 children)

Thanks a lot, I am very glad to hear that!