In XS, how do I get the address of variables from its name?

In XS, how can I turn a string containing the variable name into my address, I want to do something like the following perl code:

our $var = 1;
print ${$main::{var}};
+3
source share
1 answer

In perlguts says:

If you know the name of a scalar variable, you can get a pointer to its SV using the following:

SV*  get_sv("package::varname", FALSE);
+9
source

Source: https://habr.com/ru/post/1711299/


All Articles