Skip to content
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

dylib::get_function() is "neither here nor there" #54

Open
eyalroz opened this issue Jun 21, 2022 · 0 comments
Open

dylib::get_function() is "neither here nor there" #54

eyalroz opened this issue Jun 21, 2022 · 0 comments

Comments

@eyalroz
Copy link
Contributor

eyalroz commented Jun 21, 2022

I'm looking at this kind of line, which we would now write with dylib (2.0):

auto mod = lib.get_function<float *, const char *>("driver::factory");

I find that's not good enough. It's neither here nor there. If you want something fully dynamic, then don't even pass the type via a template, but as a string, e.g.

lib.get_function("driver::factory(float *, const char *)");

where users would manage the calling conventions themselves using a void*.

Similarly, you would also accept

lib.get_function("foo driver::factory(float *, const char *)");

for any foo, i.e. be willing to ignore the return type in the string (but also to check it if that's at all possible).

However, if you do have the namespace, name and signature at compile-time, then I would expect something like:

namespace driver {
foo (*factory)(float *, const char *) = nullptr;
} // namespace driver
lib.populate(driver::factory);

But I'm not sure the latter can be easily implemented in C++. Perhaps a macro would help here (allowing us to use both the value and the name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant