FFI::C::Union(3pm)
π FFI::C::Union π
okay bestie, welcome to FFI::C::Union β the Perl module that's literally the union data instance for FFI, from the User Contributed Perl Documentation section of your man pages (section 3pm, iykyk). this is version 0.15 and she is serving β¨
π¦ SYNOPSIS π¦
here's the whole vibe, copy-paste ready, no cap:
use FFI::C::UnionDef;
my $def = FFI::C::UnionDef->new(
name => 'anyint_t',
class => 'AnyInt',
members => [
u8 => 'uint8',
u16 => 'uint16',
u32 => 'uint32',
],
);
my $int = AnyInt->new({ u8 => 42 });
printf "0x%x\n", $int->u32; # 0x2a on Intel
see that last line? 0x2a on Intel. that's the union doing union things π«Ά
πΈ DESCRIPTION πΈ
so this class represents an instance of a C union. that's the whole main character energy of the file. π
how do you even get one? two ways, bestie:
- you can create it using
newon the generated class β but only if that class was specified for theFFI::C::UnionDef - or you can use the
createmethod over onFFI::C::UnionDef
and here's the iconic part: for each member defined in the FFI::C::UnionDef, there's an accessor for the FFI::C::Union instance. every single one. no member left behind π
π§ CONSTRUCTOR π§
β¨ new β¨
FFI::C::UnionDef->new( class => 'User::Union::Class', ... );
my $instance = User::Union::Class->new;
creates a new instance of the union. that's it, that's the job, and she ate π₯
π SEE ALSO π
go read these too, they're all part of the friend group:
FFI::CFFI::C::ArrayFFI::C::ArrayDefFFI::C::DefFFI::C::FileFFI::C::PosixFileFFI::C::StructFFI::C::StructDefFFI::C::UnionFFI::C::UnionDefFFI::C::UtilFFI::Platypus::Record
π AUTHOR π
Graham Ollis <plicease@cpan.org> β absolute legend, we stan π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2020-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
ok so that's the whole page bestie, go forth and union π
and that's a wrap! this page came to you from perl v5.36.0, dated 2023-02-06, filed under FFI::C::Union(3pm) β mwah, slay, periodt β¨ππ
π¦ where this page comes from
- debian bookworm: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms