Category : abi

Let’s say we’re building a library mylib and below is the header file # mylib.h // some include #ifdef ENABLE_XXX_FEATURE #include <dependent_library_a> #include <dependent_library_b> #endif class MyLib { … #ifdef ENABLE_XXX_FEATURE void feature_xxx_related_function(type_in_dependent_library_a param1, type_in_dependent_library_b param2); #endif }; I want to use the ENABLE_XXX_FEATURE definition to control the visibility of some code blocks. If user ..

Read more

Consider an application built using a compiler version (e.g. 1.x). Consider a dynamic library built using the same compiler but of a different version (e.g. 1.y). The interface exported by the dynamic library doesn’t contain C++ specific constructs (e.g. std::vector, etc.); however it does contain struct definitions (containing POD types and other struct types only) ..

Read more

I am working on a SIMD wrapper for C++, the base type looks like the following union: union u{ __m128d sse; double c[2]; }; In the following, I want to look at the ABI for Linux. e.g. __m128d f(__m128d a, __m128d b){ return b; } compiles to f(double __vector(2), double __vector(2)): vmovaps xmm0, xmm1 ret ..

Read more

Consider the following example code for a dynamic library: template <typename> struct foo_template { static inline int get() { static int val = 0; return ++val; } }; struct foo { template <typename> static inline int get() { static int val = 0; return ++val; } }; template <typename> inline int get() { static int ..

Read more

Can’t call a class method using libffi library working with function calling convention. On x86, it turned out to write code using _asm rates, transferring that code to x64 no longer works since there is a different system for passing parameters to a function. There is a description in the article https://docs.microsoft.com/ru-ru/cpp/build/x64-calling-convention?view=msvc-160. I want to ..

Read more

The common explanation for not fixing some issues with C++ is that it would break the ABI and require recompilation, but on the other hand I encounter statements like this: Honestly, this is true for pretty much all C++ non-POD types, not just exceptions. It is possible to use C++ objects across library boundaries but ..

Read more