syphilis has asked for the wisdom of the Perl Monks concerning the following question:
That gives me the numeric values of pointers to the mpfr_mul and mpfr_add functions, and I can readily construct the pointers to those functions from that info.use strict; use warnings; use Inline C => Config => LIBS => '-lmpfr -lgmp', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include <mpfr.h> #define FUNC_PTR(x) newSViv(PTR2IV(x)) SV* get_mpfr_mul_func_ptr() { return newSViv(PTR2IV(mpfr_mul)); } SV * get_mpfr_add_func_ptr() { return newSViv(PTR2IV(mpfr_add)); } EOC print get_mpfr_mul_func_ptr(), "\n"; print get_mpfr_add_func_ptr(), "\n";
But I don't know of any tricks that would allow that to happen.SV * get_func_ptr(char * func_name) { /* code that returns the pointer value for the requested function */ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [OT: C] Getting pointers to functions
by Corion (Patriarch) on Dec 30, 2016 at 09:07 UTC | |
by syphilis (Archbishop) on Dec 31, 2016 at 07:48 UTC | |
|
Re: [OT: C] Getting pointers to functions
by BrowserUk (Patriarch) on Dec 30, 2016 at 14:02 UTC | |
by syphilis (Archbishop) on Dec 31, 2016 at 08:19 UTC | |
|
Re: [OT: C] Getting pointers to functions
by RonW (Parson) on Jan 04, 2017 at 23:51 UTC | |
by syphilis (Archbishop) on Jan 05, 2017 at 08:18 UTC |