explain_strtol_or_die(3)
π explain_strtol_or_die β like, the manual page, but make it make sense π
okay bestie, welcome to explain_strtol_or_die(3) from the Library Functions Manual β¨ this one lives in libexplain and it's literally here to turn a string into a long and then tell you exactly what went wrong if it can't. no cap. π«Ά
β¨ NAME β¨
explain_strtol_or_die β convert a string to a long integer and report errors π¦
πΈ SYNOPSIS πΈ
#include <libexplain/strtol.h>
long explain_strtol_or_die(const char *nptr, char **endptr, int base);
long explain_strtol_on_error(const char *nptr, char **endptr, int base))
yes the second one has a spare ) at the end. that's how it's printed. i am not touching it, that's canon π
π DESCRIPTION π
So there's two functions here and they're basically siblings, okay? One is the dramatic one and one is the chill one. π
The explain_strtol_or_die function is used to call the strtol(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtol(3) function, and then the process terminates by calling exit(EXIT_FAILURE). like. it's over. it said what it said. π
The explain_strtol_on_error function is used to call the strtol(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtol(3) function, but still returns to the caller. so it also tells you everything, but it lets you keep living your life. main character energy but polite. π
π the arguments, bestie
nptrβ thenptr, exactly as to be passed to thestrtol(3)system call. exact same one, no edits, no remix.endptrβ theendptr, exactly as to be passed to thestrtol(3)system call. again: verbatim, untouched, iconic.baseβ thebase, exactly as to be passed to thestrtol(3)system call. yes queen, pass it straight through. β¨
β RETURN VALUE β
The explain_strtol_or_die function only returns on success, see strtol(3) for more information. On failure, prints an explanation and exits, it does not return. like, does not. don't sit there waiting for it, it already left the group chat. π
The explain_strtol_on_error function always returns the value return by the wrapped strtol(3) system call. always. every single time. π«Ά
π EXAMPLE π
The explain_strtol_or_die function is intended to be used in a fashion similar to the following example:
long result = explain_strtol_or_die(nptr, endptr, base);
that's it. that's the whole vibe. one line, does the thing, explains itself if it can't. obsessed. π
π¦ SEE ALSO π¦
strtol(3)β convert a string to a long integerexplain_strtol(3)β explainstrtol(3)errorsexit(2)β terminate the calling process
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
and that's the whole page, bestie π this was explain_strtol_or_die(3), page number 3, straight out of the Library Functions Manual β libexplain version 1.4, copyright 2009 Peter Miller, and the footer says the exact same title again because symmetry is slay π
β¨ go forth and convert strings responsibly, mwah π«Άπ
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms