XDF_CLOSEST_TYPE(3)
π XDF_CLOSEST_TYPE(3) π
okay bestie, welcome to the xdffileio library manual β this is page XDF_CLOSEST_TYPE(3) and it's genuinely so useful, i promise. sit down, hydrate, let's get into it π«Ά
β¨ NAME β¨
xdf_closest_type β returns a compatible data type π
πΈ SYNOPSIS πΈ
#include <xdfio.h>
int xdf_closest_type(struct xdf* xdf, enum xdftype target);
π¦ DESCRIPTION π¦
so basically, xdf_closest_type() looks at all the data types your file supports β the file being the one referenced by xdf β and picks the one that's closest to the target you passed in. and then?? you can safely use that selected type in a call to xdf_set_chconf(3) with the XDF_CF_STOTYPE field. it's giving matchmaker but for types, fr fr π
the selection algorithm runs on 3 criterions, and they're listed by priority β most important first, no skipping the line:
- data size β this one forces the selected type to have a data size (aka the number of bytes needed to represent the value) that is equal to or bigger than the target's. and within that, it prefers sizes closest to the target's size. so like, big enough, but not extra for no reason β¨
- signed/unsigned type β this criterion tries to pick a type with the same signeness as
target(signed stays signed, unsigned stays unsigned, we don't switch teams π) - float/integer value β finally, this one tries to select a floating point type if
targetisfloatordouble, or an integer data type iftargetis an integer type. floaty stays floaty, whole stays whole π
and here's the cute consequence: if target is actually supported by the underlying file format of xdf, the function is ensured to return target. iconic behaviour honestly π
β RETURN VALUE β
xdf_closest_type() returns the selected data type when it succeeds π otherwise it returns -1 and sets errno appropriately. sad girl hours but at least you get an errno π
π ERRORS π
EINVALβ thexdfpointer isNULL, or the argumenttypeis not an admissibleenum xdftypevalue. (not me passing a nonsense enum π)
π§ SEE ALSO π§
that's the whole page bestie, you ate it π
sign-off time: this one came from EPFL, dated 2010, and it lives inside the xdffileio library manual. mwah π
π¦ where this page comes from
- debian bookworm: libxdffileio-dev 0.3-4 Β· LGPL-3.0-or-later
- debian trixie: libxdffileio-dev 0.3-4+b2 Β· LGPL-3.0-or-later
- fedora 43: xdffileio-devel 0.3-23.fc43 Β· LGPL-3.0-or-later
- fedora 43: xdffileio-devel 0.3-23.fc43 Β· LGPL-3.0-or-later
- fedora 44: xdffileio-devel 0.3-24.fc44 Β· LGPL-3.0-or-later
- fedora 44: xdffileio-devel 0.3-24.fc44 Β· LGPL-3.0-or-later
- ubuntu jammy: libxdffileio-dev 0.3-4 Β· LGPL-3.0-or-later
- ubuntu noble: libxdffileio-dev 0.3-4ubuntu3 Β· LGPL-3.0-or-later
- ubuntu questing: libxdffileio-dev 0.3-4ubuntu3
- ubuntu resolute: libxdffileio-dev 0.3-4ubuntu4 Β· LGPL-3.0-or-later
- ubuntu stonking: libxdffileio-dev 0.3-4ubuntu4 Β· LGPL-3.0-or-later
- Copyright 2010 (c) EPFL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms