shac ron ₪ on Nostr: Alright, here’s what I want. A compiler annotation for class methods that create a ...
Alright, here’s what I want. A compiler annotation for class methods that create a C symbol that takes the same arguments and the ‘this’ pointer equivalent as the first arg.
class Foo {
public:
int value() __attribute__((c_linkage, foo_get_value));
// …
};
This defines
external “C” int foo_get_value(Foo *this)
and tags it for the linker.
If the linker is smart, it will create a C++ style call at call sites, putting ‘this’ in the proper register. If it’s dumb, it will call the stub emitted by the compiler that trivially does this. https://ioc.exchange/@shac/113132207933183105
class Foo {
public:
int value() __attribute__((c_linkage, foo_get_value));
// …
};
This defines
external “C” int foo_get_value(Foo *this)
and tags it for the linker.
If the linker is smart, it will create a C++ style call at call sites, putting ‘this’ in the proper register. If it’s dumb, it will call the stub emitted by the compiler that trivially does this. https://ioc.exchange/@shac/113132207933183105