A compound type analagous to a C struct.
gccjit;;struct_ is a subclass of gccjit;;type (and thus of gccjit;;object in turn).
A field within a gccjit;;struct_.
gccjit;;field is a subclass of gccjit;;object.
You can model C struct types by creating gccjit;;struct_ and gccjit;;field instances, in either order:
struct coord {double x; double y; };
you could call:
gccjit::field field_x = ctxt.new_field (double_type, "x"); gccjit::field field_y = ctxt.new_field (double_type, "y"); std::vector fields; fields.push_back (field_x); fields.push_back (field_y); gccjit::struct_ coord = ctxt.new_struct_type ("coord", fields);
struct node { int m_hash; struct node *m_next; };
like this:
gccjit::struct_ node = ctxt.new_opaque_struct_type ("node"); gccjit::type node_ptr = node.get_pointer (); gccjit::field field_hash = ctxt.new_field (int_type, "m_hash"); gccjit::field field_next = ctxt.new_field (node_ptr, "m_next"); std::vector fields; fields.push_back (field_hash); fields.push_back (field_next); node.set_fields (fields);
Construct a new field, with the given type and name.
Construct a new struct type, with the given name and fields.
Construct a new struct type, with the given name, but without specifying the fields. The fields can be omitted (in which case the size of the struct is not known), or later specified using gcc_jit_struct_set_fields().