ensure


Description:

[ Version ( since = "2.34" ) ]
public void ensure ()

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 ensure guarantees that the type's _get_type method is called.

Parameters:

type

a Type




2022 vala-language.org