explain_strtoull_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ explain_strtoull_or_die ✨

okay bestie, so you know how strtoull(3) exists and it's giving "I convert strings to integers" but also it's giving "and I will NOT tell you what went wrong"? yeah. that's where this little icon comes in. welcome to explain_strtoull_or_die(3) from the Library Functions Manual πŸ’–


🌸 NAME 🌸

explain_strtoull_or_die β€” convert string to integer and report errors

like. the name literally tells you everything. it converts. it reports. it's a whole package. no cap.


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/strtoull.h>
unsigned long long explain_strtoull_or_die(const char *nptr, char
**endptr, int base);
unsigned long long explain_strtoull_on_error(const char *nptr, char
**endptr, int base))

okay first of all: yes, that trailing )) in the second one is really there, I'm not editing it, I don't make the rules, I just report them πŸ’… also like, lowkey obsessed with how explain_strtoull_on_error gets two closing parens and _or_die only gets one. main character energy for real.


πŸ¦‹ DESCRIPTION πŸ¦‹

the _or_die one 🫢

The explain_strtoull_or_die function is used to call the strtoull(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtoull(3) function, and then the process terminates by calling exit(EXIT_FAILURE).

so basically: it tries, and if it flops, it prints you a lil explanation and then it dies. iconic. dramatic. periodt. 😭

the _on_error one ✨

The explain_strtoull_on_error function is used to call the strtoull(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtoull(3) function, but still returns to the caller.

this one is the chill sibling β€” it tells you what went wrong, but it does NOT end the whole program. it just comes back and hands you the news. very mature of it honestly.

the args, bestie 🌈

  • nptr β€” The nptr, exactly as to be passed to the strtoull(3) system call. like, verbatim. no glow-up, no filter, straight through.
  • endptr β€” The endptr, exactly as to be passed to the strtoull(3) system call. same energy, untouched.
  • base β€” The base, exactly as to be passed to the strtoull(3) system call. yes, base 10, base 16, base whatever, exactly as-is. don't come for me.
fr fr, all three of these get passed through exactly as given. this function is not out here editing your arguments, it's not that kind of friend.

πŸ’œ RETURN VALUE πŸ’œ

The explain_strtoull_or_die function only returns on success, see strtoull(3) for more information. On failure, prints an explanation and exits, it does not return.

so like. if it comes back? slay, that's a win. if it doesn't come back? that's the whole point, babe. πŸ’€

The explain_strtoull_on_error function always returns the value return by the wrapped strtoull(3) system call.

^^ (yes, "return" not "returned", that's how it's written, I'm keeping it, don't @ me) this one always comes back with whatever the wrapped strtoull(3) gave it. reliable queen. πŸ‘‘


πŸ“ EXAMPLE πŸ“

The explain_strtoull_or_die function is intended to be used in a fashion similar to the following example:

unsigned long long result = explain_strtoull_or_die(nptr, endptr, base);

look at her. one line. no error handling written by you. she handles it. she handles everything. 🧚


⭐ SEE ALSO ⭐

go read these too, they're the supporting cast and they ate. πŸ”₯


libexplain version 1.4 Copyright (C) 2009 Peter Miller


okay and that's the whole page bestie πŸ’– this was explain_strtoull_or_die(3), part of the Library Functions Manual, from libexplain version 1.4, Β© 2009 Peter Miller β€” big love to Peter for writing it, and big love to you for reading all the way down here. go convert some strings, but like, responsibly. mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from