Note that there are some explanatory texts on larger screens.

plurals
  1. POC# AnyCPU library using x86/x64 C API - packing structures, calls and callbacks
    primarykey
    data
    text
    <p>I`m searching and trying all sort of solutions for like two weeks now to make the following possible: port 32-bit libraries and C++/.NET wrappers to 64-bit (for C++) and AnyCpu (for .NET).</p> <p>There is:</p> <ul> <li>a C++ library which exposes a C-style interface further referred as "The Brain" (this is how we all call it)</li> <li>a second C++ library (DDC) which uses The Base is more like a wrapper for it, in the way that it packs a very nice interface</li> <li>a .NET library (DDN) which uses The Base and acts like a wrapper for C# and VB</li> <li>a JAVA library (DDJ) [ not important, we have separate development to handle this ]</li> <li>a PYTHON library (DDP) [ not important neither ]</li> </ul> <p>The libraries are huge, in the way that there are thousands of structures and functions (interfacing with databases and with some various Ethernet devices). There is lots of functionality which I don`t even know why is kept in the code, but requirements are requirements and must be obeyed...</p> <p>The entire driver and database connector had only 32-bit configurations. There is no relevant documentation on anything inside and a lot of code had to be modified (not rewritten or refactored, but modified).</p> <p>All the structures are aligned on 4 bytes, marshalling between .net and C API works ok on 32-bit.</p> <p><strong>The new requirement is to create AnyCPU .NET configuration which to use the 64-bit respectively 32-bit Base according to the system the VB/C# application runs on.</strong></p> <p>So far so good - DDC works nice with The Base. but when it comes to DDN - there is a whole lot of s### happening: <strong>the structures to be marshalled and unmarshalled with The Base have a pack on 4 bytes...</strong> Therefore, the alignment of the Base structures has been switched to 4 bytes for both 32-bit and 64-bit (was 4 respectively 8 bytes).</p> <p><strong>My initial plan</strong> was with alignment on 4 and 8 bytes for 32-but respectively 64-bit configurations, but there is a lot of work to do in the .NET API interfacing with the Base C wrapper... the calls and callbacks are separated within different namespaces, each including the respective library, but the structures are a pain...</p> <p><strong>The second plan</strong> was to align everything with either 4 or 8 but there are a lot of warnings regarding the packing of structures and unary operators... Besides those warnings, nothing works nice anymore. Heap corruptions, shutdown crashes etc..</p> <p><strong>A third solution</strong> would be to switch back to solution 1 and create structures with appropriate packs on both namespaces (the namespace interacting with 32-bit Base library and the namespace interacting with the 64-bit Base library)</p> <p>I would greatly appreciate any feedback. Please do not hesitate to ask for more information if anything is unclear.</p> <p>Thank you all!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload