DLERROR(3POSIX)

πŸ’– dlerror β€” the POSIX Programmer's Manual, bestie edition πŸ’–

okay so quick lil note before we dive in: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the details of Linux behavior, fr fr), or the interface might not even be implemented on Linux at all. 😭


✨ NAME ✨

dlerror β€” get diagnostic information


πŸŽ€ SYNOPSIS πŸŽ€

#include <dlfcn.h>

char *dlerror(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: dlerror() shall return a null-terminated character string (with no trailing <newline>, bestie, keep it tidy) that describes the last error that occurred during dynamic linking processing. It's giving "here's what just went wrong, girlie". πŸ’…

If no dynamic linking errors have occurred since the last invocation of dlerror(), then dlerror() shall return NULL. So the way that works is: invoking dlerror() a second time, immediately following a prior invocation, shall result in NULL being returned. It's a one-time tea spill, basically. πŸ“

It is implementation-defined whether or not the dlerror() function is thread-safe. A thread-safe implementation shall return only errors that occur on the current thread. iykyk. 🧚


πŸ‘‘ RETURN VALUE πŸ‘‘

If successful, dlerror() shall return a null-terminated character string; otherwise, NULL shall be returned.

The application shall not modify the string returned. Like, hands off, bestie. πŸ™ˆ

The returned pointer might be invalidated, or the string content might be overwritten, by a subsequent call to dlerror() in the same thread (if dlerror() is thread-safe) or in any thread (if dlerror() is not thread-safe). The returned pointer might also be invalidated if the calling thread is terminated. So don't be clinging to that pointer, it's not loyal. πŸ’€


🌸 ERRORS 🌸

No errors are defined.

The following sections are informative. (Yes girl, that means they're the bonus content. ⭐)


🌈 EXAMPLES 🌈

The following example prints out the last dynamic linking error:

...
#include <dlfcn.h>

char *errstr;

errstr = dlerror();
if (errstr != NULL)
    printf ("A dynamic linking error occurred: (%s)\n", errstr);
...

ate, no crumbs. πŸ”₯


πŸ’œ APPLICATION USAGE πŸ’œ

Depending on the application environment with respect to asynchronous execution events β€” such as signals, or other asynchronous computation sharing the address space β€” conforming applications should use a critical section to retrieve the error pointer and buffer. Basically: protect your girl, don't let the async events snatch her mid-read. 🫢


⭐ RATIONALE ⭐

None.

(the silence is loud, bestie. 😭)


🧚 FUTURE DIRECTIONS 🧚

None.


πŸ”₯ SEE ALSO πŸ”₯

  • dlclose()
  • dlopen()
  • dlsym()

The Base Definitions volume of POSIX.1‐2017, <dlfcn.h>


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie πŸ’– this lil masterpiece was brought to you by IEEE/The Open Group, 2017, and the manual page is literally called DLERROR(3POSIX). slay, go forth and check your dynamic linking errors responsibly. βœ¨πŸ‘‘πŸŽ€