Function

GObjecttype_ensure

since: 2.34

Declaration [src]

void
g_type_ensure (
  GType type
)

Description [src]

Ensures that the indicated type has been registered with the type system, and its _class_init() method has been run.

In theory, simply calling the type’s _get_type() method (or using the corresponding macro) is supposed take care of this. However, _get_type() methods are often marked G_GNUC_CONST for performance reasons, even though this is technically incorrect (since G_GNUC_CONST requires that the function not have side effects, which _get_type() methods do on the first call). As a result, if you write a bare call to a _get_type() macro, it may get optimized out by the compiler. Using g_type_ensure() guarantees that the type’s _get_type() method is called.

Available since: 2.34

Parameters

type

Type: GType

A GType.