variable#

A library’s global variable as a Perl scalar.

Synopsis#

my $optind = Peta::FFI::variable($libc, "optind", "i");
print $$optind, "\n";        # reads the C variable
$$optind = 1;                # writes it

A reference to a scalar bound to the variable: reading $$var reads the C variable at that moment, assigning to it writes the variable, for any type store can write; a p variable is read-only. The library stays loaded while the scalar lives. Croaks when the library has no such symbol.