-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How to build library without inlining #3664
Comments
Right. So you use a language that has an FFI to call C functions. But you cannot use static inline function definitions. You raise a good point. Let's get rid of static inline functions. We generate an .a archive-library by default. |
My C knowledge and especially building them on linux / windows is quite limited. I cannot help here much but I can give some thoughts
|
The question is for which compilation unit the object code (machine code) is generated. In C, every .c file is a compilation unit that leads to a .o object file. The .o are combined in the final executable. With normal functions, the .c file that defines the function body gets to hold the object code for it. But what if the inline function is only defined in a .h header and not in a .c file? |
I am not sure whether I understand everything of your comment, as here I only have very few experience. I just checked, there was a similar problem in librdkafka. The solution was actually to remove the inline attribute (confluentinc/librdkafka@7207083) |
This issue is still relevant. Creating bindings for a Rust project we faced the same problems. Lots of high level convenience functions are declared The suggested solution to replace As a workaround we use a script that replaces Was there any progress on this issue from your side? |
@MattesWhite Your workaround seems to be the best solution. |
That‘s a tough issue. On one hand it would be great to enable language bindings/generation. On the other hand inline functions are great. In an ideal world my preferred solution would be this: We wrap static inline methods inside a macro. UA_INLINE(declaration, implementation) That macro can be controlled to generate either 1) a static inline method or 2) a UA_EXPORT method declaration or 3) the method implementation. Then we can have an optional single .c compilation unit that includes the headers with a macro configuration that generates normal code. Do you have some bandwidth to start working in that direction? |
I'm willing to try but can't say when I have the time left to dig in. Just for clarification your suggestion is to write the #define UA_INLINE(name, decl, impl)
#ifndef UA_EXPORT_INLINES
static UA_INLINE_DECL decl impl
#else
#ifndef UA_INLINE##name
decl
#define UA_INLINE##name
#else
impl
#endif
#endif Disclaimer: I haven't written such macros in a while but the idea should be clear |
Yeah, exactly! #define UA_INLINE(decl, impl)
#if defined(UA_INLINE_EXPORT) and defined(UA_INLINE_IMPL)
decl impl
#elif defined(UA_INLINE_EXPORT)
UA_EXPORT decl ;
#else
static inline decl impl
#endif With UA_INLINE(UA_Variant * UA_Variant_init(void),
{ return UA_new(&UA_TYPES[UA_TYPES_VARIANT]); }) |
This is being implemented in #5445. |
I am having problems getting |
Yes, we need to add the inline-wrapper handline from #5445 to the auto-generated methods.
|
I made a pull request with 2 initial commits #5926 , please let me know if the style is acceptable or if I need to change anything , or do it differently for the rest of the changes : D |
Description
The compiled libraries (https://github.com/open62541/open62541/releases/download/v1.1-rc1/open62541-linux64.tar.gz) makes heavy use of inlining. Therefore a lot of functions are missing
while trying to call the SO from other programming languages than C ( Example the D Programming Language).
It is almost impossible to get the client example running due to this missing references:
Could you add in the documentation a step, how to compile the library without inlining?
Also it would be interesting how a static library (
*.a
) could be generated instead of shared object (*.so
).Background Information / Reproduction Steps
Used CMake options:
Checklist
Please provide the following information:
UA_LOGLEVEL
set as low as necessary) attachedThe text was updated successfully, but these errors were encountered: