explain_strtoll(3)
πΈ explain_strtoll β ok bestie, let's decode ur strtoll(3) L's πΈ
Library Functions Manual Β· the libexplain era Β· explain_strtoll(3)
β¨ NAME β¨
explain_strtoll β no cap, this is the one that explains ur strtoll(3) errors π
π SYNOPSIS π
#include <libexplain/strtoll.h>
const char *explain_strtoll(const char *nptr, char **endptr, int base);
const char *explain_errno_strtoll(int errnum, const char *nptr, char
**endptr, int base);
void explain_message_strtoll(char *message, int message_size, const char
*nptr, char **endptr, int base);
void explain_message_errno_strtoll(char *message, int message_size, int
errnum, const char *nptr, char **endptr, int base);
π¦ DESCRIPTION π¦
Okay so, these functions? They're ur little group chat that explains errors handed back by the strtoll(3) system call. Four of them. All icons, all doing slightly different things. Let's get into it π«Ά
π explain_strtoll
const char *explain_strtoll(const char *nptr, char **endptr, int base);
The explain_strtoll function is how u get an explanation of an error that came back from strtoll(3). Like, the least the message will contain is the value of strerror(errno), but honestly? Usually it does so much better and tells u the underlying cause in way more detail. It's giving detective energy fr fr π
The errno global variable is what gets used to obtain the error value that needs decoding.
nptrβ the originalnptr, exactly as passed to thestrtoll(3)system call. no edits, no glow-up, just as-is β¨endptrβ the originalendptr, exactly as passed to thestrtoll(3)system call.baseβ the originalbase, exactly as passed to thestrtoll(3)system call.
Returns:
The message explaining the error. Heads up tho: this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. So it will get overwritten by the next call to any libexplain function that shares this buffer β including calls from other threads π
Note: this function is not thread safe, because it shares a return buffer across all threads, and so do many other functions in this library. it's giving communal, and not in a cute way π
Example: this function is intended to be used in a fashion similar to the following example:
long long result = strtoll(nptr, endptr, base);
if (result < 0)
{
fprintf(stderr, "%s\n", explain_strtoll(nptr, endptr, base));
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_strtoll_or_die(3) function. convenient much? π
π explain_errno_strtoll
const char *explain_errno_strtoll(int errnum, const char *nptr, char
**endptr, int base);
The explain_errno_strtoll function is how u get an explanation of an error returned by the strtoll(3) system call. Again, the least the message will contain is the value of strerror(errno), but usually it goes way harder and shows u the underlying cause in more detail.
errnumβ the error value to be decoded, usually grabbed from theerrnoglobal variable right before this function is called. This one matters if u need to run any code between the system call u wanna explain and this function, because many libc functions will alter the value oferrnoand then ur explanation is explaining the wrong thing πnptrβ the originalnptr, exactly as passed to thestrtoll(3)system call.endptrβ the originalendptr, exactly as passed to thestrtoll(3)system call.baseβ the originalbase, exactly as passed to thestrtoll(3)system call.
Returns:
The message explaining the error. Same tea as before: this message buffer is shared by all libexplain functions which don't supply a buffer in their argument list, and it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads.
Note: not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too. periodt π
Example: intended to be used in a fashion similar to:
long long result = strtoll(nptr, endptr, base);
if (result < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_strtoll(err, nptr,
endptr, base));
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_strtoll_or_die(3) function. slay β¨
π§ explain_message_strtoll
void explain_message_strtoll(char *message, int message_size, const char
*nptr, char **endptr, int base);
The explain_message_strtoll function gets u an explanation of an error returned by the strtoll(3) system call. Least the message will contain is the value of strerror(errno), but usually it does much better and points at the underlying cause in more detail.
The errno global variable will be used to obtain the error value to be decoded.
messageβ the location where the returned message gets stored. If a suitable message return buffer is supplied, this function is thread safe. π that's the upgrade bestiemessage_sizeβ the size in bytes of the location in which to store the returned message.nptrβ the originalnptr, exactly as passed to thestrtoll(3)system call.endptrβ the originalendptr, exactly as passed to thestrtoll(3)system call.baseβ the originalbase, exactly as passed to thestrtoll(3)system call.
Example: intended to be used in a fashion similar to:
long long result = strtoll(nptr, endptr, base);
if (result < 0)
{
char message[3000];
explain_message_strtoll(message, sizeof(message), nptr,
endptr, base);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_strtoll_or_die(3) function. we love a pre-packaged moment π
π explain_message_errno_strtoll
void explain_message_errno_strtoll(char *message, int message_size, int
errnum, const char *nptr, char **endptr, int base);
The explain_message_errno_strtoll function is used to obtain an explanation of an error returned by the strtoll(3) system call. Least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.
messageβ the location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe πmessage_sizeβ the size in bytes of the location in which to store the returned message.errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. This is necessary if u need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. stay vigilant bestie πnptrβ the originalnptr, exactly as passed to thestrtoll(3)system call.endptrβ the originalendptr, exactly as passed to thestrtoll(3)system call.baseβ the originalbase, exactly as passed to thestrtoll(3)system call.
Example: intended to be used in a fashion similar to:
long long result = strtoll(nptr, endptr, base);
if (result < 0)
{
int err = errno;
char message[3000];
explain_message_errno_strtoll(message, sizeof(message), err,
nptr, endptr, base);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_strtoll_or_die(3) function. iconic behavior, truly π₯
β SEE ALSO β
strtoll(3)β convert a string to a long integerexplain_strtoll_or_die(3)β convert a string to a long integer and report errors
iykyk, these two are the whole squad π―
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
and that's the whole page bestie!! πΈ this was explain_strtoll(3) from the Library Functions Manual, brought to u by libexplain version 1.4, copyright (C) 2009 Peter Miller β mwah, take care of ur errno, drink water, and go convert some strings responsibly π
β¨π¦
π¦ 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