xdf_closest_type man page

xdf_closest_type — Returns a compatible data type


#include <xdfio.h>

int xdf_closest_type(struct xdf* xdf, enum xdftype target);


xdf_closest_type() selects among the data types supported by the file referenced by xdf the type that is the closest to the target argument. The selected type can then be safely used in a call to xdf_set_chconf(3) with the XDF_CF_STOTYPE field.

The selection algorithm is based on the 3 following criterions (cited by priority, i.e. most important cited first): data size, signed/unsigned type, float/integer value. The data size criterion forces the selected type to have a data size (number of byte to represent the value) equal or bigger than the one of the target type (with a preference with sizes the closest to the size of target). The signed/unsigned criterion tries to select a type that has the same signeness (signed or unsigned data type) as the target. Finally the float/integer criterion tries to select a floating point type if target is float or double or an integer data type if target is an integer type.

As a consequence, if target is supported by the underlying file format of xdf, the function is ensured to return target.

Return Value

xdf_closest_type() returns the selected data type in case of success, otherwise -1 and errno is set appropriately.


the xdf pointer is NULL, or the argument type is not an admissible enum xdftype value.

See Also



Explore man page connections for xdf_closest_type(3).