top | item 46956821

(no title)

Mikhail_Edoshin | 19 days ago

Here is a use case. I have a function that takes variable parameters, so there is no formal type control:

    int Foo(int a, ...);
But in fact the types are restricted depending on a call type, set by 'a'. So I could add a wrapper for a specific variant:

    static inline FooVar1(char b, long c)
    {
        return Foo(FOO_VAR_1, b, c);
    }
All the wrapper does is adds a bit of type control during compilation, otherwise it must be just a function call to 'Foo'. It is like a supermacro. It does make sense to put that into 'static inline' in a header.

discuss

order

1718627440|19 days ago

Then what the FFI needs to target is `int Foo(int a, ...);`. FooVar1 is just a convenience method for the C language binding.

yxhuvud|19 days ago

That is not an option - it may be layers on layers of them and force you to recreate half the library and force you to have to redo subsequent version updates in your code. Then a shim is the preferred solution. But anything that requires a C compiler for FFI is something that won't make anyone happy. Hence my claim that it really is something that needs fixing on the language or linker level.