stdlib.h(7POSIX)
โจ PROLOG โจ
okay bestie, before we even get into it, real talk: this manual 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 tea โ), or honestly the interface might not even be implemented on Linux at all. Not every platform is on the same vibe. ๐
๐ NAME ๐
stdlib.h โ standard library definitions
๐ฆ SYNOPSIS ๐ฆ
#include <stdlib.h>
๐ธ DESCRIPTION ๐ธ
okay so some of the functionality on this page actually extends the ISO C standard. If you want those extra symbols to show up, your application has to define the appropriate feature test macro (peep the System Interfaces volume of POSIX.1โ2017, Section 2.2, The Compilation Environment). No macro, no visibility. That's just how it is. ๐ญ
The <stdlib.h> header shall define the following macros, and they shall expand to integer constant expressions:
EXIT_FAILUREโ unsuccessful termination forexit(); evaluates to a non-zero value. ๐EXIT_SUCCESSโ successful termination forexit(); evaluates to0. we love a clean exit. ๐ซถ{RAND_MAX}โ the maximum value returned byrand(); at least32767.
The <stdlib.h> header shall also define the following macro, which shall expand to a positive integer expression with type size_t:
{MB_CUR_MAX}โ the maximum number of bytes in a character specified by the current locale (categoryLC_CTYPE).
And heads up: in the POSIX locale, the value of {MB_CUR_MAX} shall be 1. periodt.
The <stdlib.h> header shall define NULL as described in <stddef.h>. (yes, that's where it lives, iykyk)
The <stdlib.h> header shall define the following data types through typedef:
div_tโ structure type returned by thediv()function.ldiv_tโ structure type returned by theldiv()function.lldiv_tโ structure type returned by thelldiv()function.size_tโ as described in<stddef.h>.wchar_tโ as described in<stddef.h>.
In addition, the <stdlib.h> header shall define the following symbolic constants and macros as described in <sys/wait.h>:
WEXITSTATUSWIFEXITEDWIFSIGNALEDWIFSTOPPEDWNOHANGWSTOPSIGWTERMSIGWUNTRACED
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided. (this list is long bestie, hydrate before reading ๐ง)
void _Exit(int);
long a64l(const char *);
void abort(void);
int abs(int);
int atexit(void (*)(void));
double atof(const char *);
int atoi(const char *);
long atol(const char *);
long long atoll(const char *);
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
void *calloc(size_t, size_t);
div_t div(int, int);
double drand48(void);
double erand48(unsigned short [3]);
void exit(int);
void free(void *);
char *getenv(const char *);
int getsubopt(char **, char *const *, char **);
int grantpt(int);
char *initstate(unsigned, char *, size_t);
long jrand48(unsigned short [3]);
char *l64a(long);
long labs(long);
void lcong48(unsigned short [7]);
ldiv_t ldiv(long, long);
long long llabs(long long);
lldiv_t lldiv(long long, long long);
long lrand48(void);
void *malloc(size_t);
int mblen(const char *, size_t);
size_t mbstowcs(wchar_t *restrict, const char *restrict, size_t);
int mbtowc(wchar_t *restrict, const char *restrict, size_t);
char *mkdtemp(char *);
int mkstemp(char *);
long mrand48(void);
long nrand48(unsigned short [3]);
int posix_memalign(void **, size_t, size_t);
int posix_openpt(int);
char *ptsname(int);
int putenv(char *);
void qsort(void *, size_t, size_t, int (*)(const void *,
const void *));
int rand(void);
int rand_r(unsigned *);
long random(void);
void *realloc(void *, size_t);
char *realpath(const char *restrict, char *restrict);
unsigned short *seed48(unsigned short [3]);
int setenv(const char *, const char *, int);
void setkey(const char *);
char *setstate(char *);
void srand(unsigned);
void srand48(long);
void srandom(unsigned);
double strtod(const char *restrict, char **restrict);
float strtof(const char *restrict, char **restrict);
long strtol(const char *restrict, char **restrict, int);
long double strtold(const char *restrict, char **restrict);
long long strtoll(const char *restrict, char **restrict, int);
unsigned long strtoul(const char *restrict, char **restrict, int);
unsigned long long
strtoull(const char *restrict, char **restrict, int);
int system(const char *);
int unlockpt(int);
int unsetenv(const char *);
size_t wcstombs(char *restrict, const wchar_t *restrict, size_t);
int wctomb(char *, wchar_t);
Sneaky bonus: including the <stdlib.h> header may also make visible all symbols from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>. surprise! ๐
the following sections are informative. which is fancy-speak for "not the binding rules, just context."
๐ APPLICATION USAGE ๐
None. literally nothing. it's giving minimalism. โจ
๐ RATIONALE ๐
None. again, nothing. iconic behavior honestly.
๐ FUTURE DIRECTIONS ๐
None. the future is... also nothing. ๐ฎ
๐ SEE ALSO ๐
<limits.h><math.h><stddef.h><sys_types.h><sys_wait.h>
And from the System Interfaces volume of POSIX.1โ2017, Section 2.2, The Compilation Environment: _Exit(), a64l(), abort(), abs(), atexit(), atof(), atoi(), atol(), bsearch(), calloc(), div(), drand48(), exit(), free(), getenv(), getsubopt(), grantpt(), initstate(), labs(), ldiv(), malloc(), mblen(), mbstowcs(), mbtowc(), mkdtemp(), posix_memalign(), posix_openpt(), ptsname(), putenv(), qsort(), rand(), realloc(), realpath(), setenv(), setkey(), strtod(), strtol(), strtoul(), system(), unlockpt(), unsetenv(), wcstombs(), wctomb()
๐ COPYRIGHT ๐
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 .
okay that's the whole page bestie, you ate that ๐ โจ
and for the cute sign-off: this whole thing is brought to you by IEEE/The Open Group, dated 2017 โ that's the <pink>stdlib.h(7POSIX)</pink> energy, no cap. ๐๐ฆ
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms