Module stdinc
dep_sdl3
only.Expand description
SDL provides its own implementation of some of the most important C runtime functions.
Using these functions allows an app to have access to common C functionality without depending on a specific C runtime (or a C runtime at all). More importantly, the SDL implementations work identically across platforms, so apps can avoid surprises like snprintf() behaving differently between Windows and Linux builds, or itoa() only existing on some platforms.
For many of the most common functions, like SDL_memcpy
, SDL might just call
through to the usual C runtime behind the scenes, if it makes sense to do
so (if it’s faster and always available/reliable on a given platform),
reducing library size and offering the most optimized option.
SDL also offers other C-runtime-adjacent functionality in this header that
either isn’t, strictly speaking, part of any C runtime standards, like
SDL_crc32()
and [SDL_reinterpret_cast
], etc. It also offers a few better
options, like SDL_strlcpy()
, which functions as a safer form of strcpy().
Structs§
- SDL_
Environment - A thread-safe set of environment variables
- SDL_
iconv_ data_ t
Constants§
- SDL_
FLT_ EPSILON - SDL_
ICONV_ E2BIG - Output buffer was too small.
- SDL_
ICONV_ EILSEQ - Invalid input sequence was encountered.
- SDL_
ICONV_ EINVAL - Incomplete input sequence was encountered.
- SDL_
ICONV_ ERROR - Generic error. Check [
SDL_GetError()
]? - SDL_
INVALID_ UNICODE_ CODEPOINT - The Unicode REPLACEMENT CHARACTER codepoint.
- SDL_
MAX_ SINT8 - SDL_
MAX_ SINT16 - SDL_
MAX_ SINT32 - SDL_
MAX_ SINT64 - SDL_
MAX_ TIME - SDL_
MAX_ UINT8 - SDL_
MAX_ UINT16 - SDL_
MAX_ UINT32 - SDL_
MAX_ UINT64 - SDL_
MIN_ SINT8 - SDL_
MIN_ SINT16 - SDL_
MIN_ SINT32 - SDL_
MIN_ SINT64 - SDL_
MIN_ TIME - SDL_
MIN_ UINT8 - SDL_
MIN_ UINT16 - SDL_
MIN_ UINT32 - SDL_
MIN_ UINT64 - SDL_
PI_ D - The value of Pi, as a double-precision floating point literal.
- SDL_
PI_ F - The value of Pi, as a single-precision floating point literal.
- SDL_
PRILLX - SDL_
PRILL_ PREFIX - SDL_
PRIL Ld - SDL_
PRIL Lu - SDL_
PRIL Lx - SDL_
PRIX32 - SDL_
PRIX64 - SDL_
PRIs32 - SDL_
PRIs64 - SDL_
PRIu32 - SDL_
PRIu64 - SDL_
PRIx32 - SDL_
PRIx64 - SDL_
SIZE_ MAX
Functions§
- SDL_
Create ⚠Environment - Create a set of environment variables
- SDL_
Destroy ⚠Environment - Destroy a set of environment variables.
- SDL_
FOURCC - Define a four character code as a Uint32.
- SDL_
GetEnvironment ⚠ - Get the process environment.
- SDL_
GetEnvironment ⚠Variable - Get the value of a variable in the environment.
- SDL_
GetEnvironment ⚠Variables - Get all variables in the environment.
- SDL_
GetMemory ⚠Functions - Get the current set of SDL memory functions.
- SDL_
GetNum ⚠Allocations - Get the number of outstanding (unfreed) allocations.
- SDL_
GetOriginal ⚠Memory Functions - Get the original set of SDL memory functions.
- SDL_
INIT_ ⚠INTERFACE - A macro to initialize an SDL interface.
- SDL_
SetEnvironment ⚠Variable - Set the value of a variable in the environment.
- SDL_
SetMemory ⚠Functions - Replace SDL’s memory allocation functions with a custom set.
- SDL_
Step ⚠BackUT F8 - Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
- SDL_
StepUT ⚠F8 - Decode a UTF-8 string, one Unicode codepoint at a time.
- SDL_
UCS4 ⚠ToUT F8 - Convert a single Unicode codepoint to UTF-8.
- SDL_
Unset ⚠Environment Variable - Clear a variable from the environment.
- SDL_abs⚠
- Compute the absolute value of
x
. - SDL_
acos ⚠ - Compute the arc cosine of
x
. - SDL_
acosf ⚠ - Compute the arc cosine of
x
. - SDL_
aligned_ ⚠alloc - Allocate memory aligned to a specific alignment.
- SDL_
aligned_ ⚠free - Free memory allocated by
SDL_aligned_alloc()
. - SDL_
asin ⚠ - Compute the arc sine of
x
. - SDL_
asinf ⚠ - Compute the arc sine of
x
. - SDL_
asprintf ⚠ - This works exactly like asprintf() but doesn’t require access to a C runtime.
- SDL_
atan ⚠ - Compute the arc tangent of
x
. - SDL_
atan2 ⚠ - Compute the arc tangent of
y / x
, using the signs of x and y to adjust the result’s quadrant. - SDL_
atan2f ⚠ - Compute the arc tangent of
y / x
, using the signs of x and y to adjust the result’s quadrant. - SDL_
atanf ⚠ - Compute the arc tangent of
x
. - SDL_
atof ⚠ - Parse a
double
from a string. - SDL_
atoi ⚠ - Parse an
int
from a string. - SDL_
bsearch ⚠ - Perform a binary search on a previously sorted array.
- SDL_
bsearch_ ⚠r - Perform a binary search on a previously sorted array, passing a userdata pointer to the compare function.
- SDL_
calloc ⚠ - Allocate a zero-initialized array.
- SDL_
ceil ⚠ - Compute the ceiling of
x
. - SDL_
ceilf ⚠ - Compute the ceiling of
x
. - SDL_
clamp - SDL_
copyp ⚠ - A macro to copy memory between objects, with basic type checking.
- SDL_
copysign ⚠ - Copy the sign of one floating-point value to another.
- SDL_
copysignf ⚠ - Copy the sign of one floating-point value to another.
- SDL_cos⚠
- Compute the cosine of
x
. - SDL_
cosf ⚠ - Compute the cosine of
x
. - SDL_
crc16 ⚠ - Calculate a CRC-16 value.
- SDL_
crc32 ⚠ - Calculate a CRC-32 value.
- SDL_exp⚠
- Compute the exponential of
x
. - SDL_
expf ⚠ - Compute the exponential of
x
. - SDL_
fabs ⚠ - Compute the absolute value of
x
- SDL_
fabsf ⚠ - Compute the absolute value of
x
- SDL_
floor ⚠ - Compute the floor of
x
. - SDL_
floorf ⚠ - Compute the floor of
x
. - SDL_
fmod ⚠ - Return the floating-point remainder of
x / y
- SDL_
fmodf ⚠ - Return the floating-point remainder of
x / y
- SDL_
free ⚠ - Free allocated memory.
- SDL_
getenv ⚠ - Get the value of a variable in the environment.
- SDL_
getenv_ ⚠unsafe - Get the value of a variable in the environment.
- SDL_
iconv ⚠ - This function converts text between encodings, reading from and writing to a buffer.
- SDL_
iconv_ ⚠close - This function frees a context used for character set conversion.
- SDL_
iconv_ ⚠open - This function allocates a context for the specified character set conversion.
- SDL_
iconv_ ⚠string - Helper function to convert a string’s encoding in one call.
- SDL_
iconv_ ⚠utf8_ locale - Convert a UTF-8 string to the current locale’s character encoding.
- SDL_
iconv_ ⚠utf8_ ucs2 - Convert a UTF-8 string to UCS-2.
- SDL_
iconv_ ⚠utf8_ ucs4 - Convert a UTF-8 string to UCS-4.
- SDL_
iconv_ ⚠wchar_ utf8 - Convert a wchar_t string to UTF-8.
- SDL_
isalnum ⚠ - Query if a character is alphabetic (a letter) or a number.
- SDL_
isalpha ⚠ - Query if a character is alphabetic (a letter).
- SDL_
isblank ⚠ - Report if a character is blank (a space or tab).
- SDL_
iscntrl ⚠ - Report if a character is a control character.
- SDL_
isdigit ⚠ - Report if a character is a numeric digit.
- SDL_
isgraph ⚠ - Report if a character is any “printable” except space.
- SDL_
isinf ⚠ - Return whether the value is infinity.
- SDL_
isinff ⚠ - Return whether the value is infinity.
- SDL_
islower ⚠ - Report if a character is lower case.
- SDL_
isnan ⚠ - Return whether the value is NaN.
- SDL_
isnanf ⚠ - Return whether the value is NaN.
- SDL_
isprint ⚠ - Report if a character is “printable”.
- SDL_
ispunct ⚠ - Report if a character is a punctuation mark.
- SDL_
isspace ⚠ - Report if a character is whitespace.
- SDL_
isupper ⚠ - Report if a character is upper case.
- SDL_
isxdigit ⚠ - Report if a character is a hexadecimal digit.
- SDL_
itoa ⚠ - Convert an integer into a string.
- SDL_
lltoa ⚠ - Convert a long long integer into a string.
- SDL_log⚠
- Compute the natural logarithm of
x
. - SDL_
log10 ⚠ - Compute the base-10 logarithm of
x
. - SDL_
log10f ⚠ - Compute the base-10 logarithm of
x
. - SDL_
logf ⚠ - Compute the natural logarithm of
x
. - SDL_
lround ⚠ - Round
x
to the nearest integer representable as a long - SDL_
lroundf ⚠ - Round
x
to the nearest integer representable as a long - SDL_
ltoa ⚠ - Convert a long integer into a string.
- SDL_
malloc ⚠ - Allocate uninitialized memory.
- SDL_max
- SDL_
memcmp ⚠ - Compare two buffers of memory.
- SDL_
memcpy ⚠ - Copy non-overlapping memory.
- SDL_
memmove ⚠ - Copy memory ranges that might overlap.
- SDL_
memset ⚠ - Initialize all bytes of buffer of memory to a specific value.
- SDL_
memset4 ⚠ - Initialize all 32-bit words of buffer of memory to a specific value.
- SDL_min
- SDL_
modf ⚠ - Split
x
into integer and fractional parts - SDL_
modff ⚠ - Split
x
into integer and fractional parts - SDL_
murmur3_ ⚠32 - Calculate a 32-bit MurmurHash3 value for a block of data.
- SDL_pow⚠
- Raise
x
to the powery
- SDL_
powf ⚠ - Raise
x
to the powery
- SDL_
qsort ⚠ - Sort an array.
- SDL_
qsort_ ⚠r - Sort an array, passing a userdata pointer to the compare function.
- SDL_
rand ⚠ - Generate a pseudo-random number less than n for positive n
- SDL_
rand_ ⚠bits - Generate 32 pseudo-random bits.
- SDL_
rand_ ⚠bits_ r - Generate 32 pseudo-random bits.
- SDL_
rand_ ⚠r - Generate a pseudo-random number less than n for positive n
- SDL_
randf ⚠ - Generate a uniform pseudo-random floating point number less than 1.0
- SDL_
randf_ ⚠r - Generate a uniform pseudo-random floating point number less than 1.0
- SDL_
realloc ⚠ - Change the size of allocated memory.
- SDL_
round ⚠ - Round
x
to the nearest integer. - SDL_
roundf ⚠ - Round
x
to the nearest integer. - SDL_
scalbn ⚠ - Scale
x
by an integer power of two. - SDL_
scalbnf ⚠ - Scale
x
by an integer power of two. - SDL_
setenv_ ⚠unsafe - Set the value of a variable in the environment.
- SDL_sin⚠
- Compute the sine of
x
. - SDL_
sinf ⚠ - Compute the sine of
x
. - SDL_
size_ ⚠add_ check_ overflow - Add two integers, checking for overflow.
- SDL_
size_ ⚠mul_ check_ overflow - Multiply two integers, checking for overflow.
- SDL_
snprintf ⚠ - This works exactly like snprintf() but doesn’t require access to a C runtime.
- SDL_
sqrt ⚠ - Compute the square root of
x
. - SDL_
sqrtf ⚠ - Compute the square root of
x
. - SDL_
srand ⚠ - Seeds the pseudo-random number generator.
- SDL_
sscanf ⚠ - This works exactly like sscanf() but doesn’t require access to a C runtime.
- SDL_
strcasecmp ⚠ - Compare two null-terminated UTF-8 strings, case-insensitively.
- SDL_
strcasestr ⚠ - Search a UTF-8 string for the first instance of a specific substring, case-insensitively.
- SDL_
strchr ⚠ - Search a string for the first instance of a specific byte.
- SDL_
strcmp ⚠ - Compare two null-terminated UTF-8 strings.
- SDL_
strdup ⚠ - Allocate a copy of a string.
- SDL_
strlcat ⚠ - Concatenate strings.
- SDL_
strlcpy ⚠ - Copy a string.
- SDL_
strlen ⚠ - This works exactly like strlen() but doesn’t require access to a C runtime.
- SDL_
strlwr ⚠ - Convert a string to lowercase.
- SDL_
strncasecmp ⚠ - Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
- SDL_
strncmp ⚠ - Compare two UTF-8 strings up to a number of bytes.
- SDL_
strndup ⚠ - Allocate a copy of a string, up to n characters.
- SDL_
strnlen ⚠ - This works exactly like strnlen() but doesn’t require access to a C runtime.
- SDL_
strnstr ⚠ - Search a string, up to n bytes, for the first instance of a specific substring.
- SDL_
strpbrk ⚠ - Searches a string for the first occurence of any character contained in a breakset, and returns a pointer from the string to that character.
- SDL_
strrchr ⚠ - Search a string for the last instance of a specific byte.
- SDL_
strrev ⚠ - Reverse a string’s contents.
- SDL_
strstr ⚠ - Search a string for the first instance of a specific substring.
- SDL_
strtod ⚠ - Parse a
double
from a string. - SDL_
strtok_ ⚠r - This works exactly like strtok_r() but doesn’t require access to a C runtime.
- SDL_
strtol ⚠ - Parse a
long
from a string. - SDL_
strtoll ⚠ - Parse a
long long
from a string. - SDL_
strtoul ⚠ - Parse an
unsigned long
from a string. - SDL_
strtoull ⚠ - Parse an
unsigned long long
from a string. - SDL_
strupr ⚠ - Convert a string to uppercase.
- SDL_
swprintf ⚠ - This works exactly like swprintf() but doesn’t require access to a C runtime.
- SDL_tan⚠
- Compute the tangent of
x
. - SDL_
tanf ⚠ - Compute the tangent of
x
. - SDL_
tolower ⚠ - Convert low-ASCII English letters to lowercase.
- SDL_
toupper ⚠ - Convert low-ASCII English letters to uppercase.
- SDL_
trunc ⚠ - Truncate
x
to an integer. - SDL_
truncf ⚠ - Truncate
x
to an integer. - SDL_
uitoa ⚠ - Convert an unsigned integer into a string.
- SDL_
ulltoa ⚠ - Convert an unsigned long long integer into a string.
- SDL_
ultoa ⚠ - Convert an unsigned long integer into a string.
- SDL_
unsetenv_ ⚠unsafe - Clear a variable from the environment.
- SDL_
utf8strlcpy ⚠ - Copy an UTF-8 string.
- SDL_
utf8strlen ⚠ - Count the number of codepoints in a UTF-8 string.
- SDL_
utf8strnlen ⚠ - Count the number of codepoints in a UTF-8 string, up to n bytes.
- SDL_
vasprintf ⚠ - This works exactly like vasprintf() but doesn’t require access to a C runtime.
- SDL_
vsnprintf ⚠ - This works exactly like vsnprintf() but doesn’t require access to a C runtime.
- SDL_
vsscanf ⚠ - This works exactly like vsscanf() but doesn’t require access to a C runtime.
- SDL_
vswprintf ⚠ - This works exactly like vswprintf() but doesn’t require access to a C runtime.
- SDL_
wcscasecmp ⚠ - Compare two null-terminated wide strings, case-insensitively.
- SDL_
wcscmp ⚠ - Compare two null-terminated wide strings.
- SDL_
wcsdup ⚠ - Allocate a copy of a wide string.
- SDL_
wcslcat ⚠ - Concatenate wide strings.
- SDL_
wcslcpy ⚠ - Copy a wide string.
- SDL_
wcslen ⚠ - This works exactly like wcslen() but doesn’t require access to a C runtime.
- SDL_
wcsncasecmp ⚠ - Compare two wide strings, case-insensitively, up to a number of wchar_t.
- SDL_
wcsncmp ⚠ - Compare two wide strings up to a number of wchar_t values.
- SDL_
wcsnlen ⚠ - This works exactly like wcsnlen() but doesn’t require access to a C runtime.
- SDL_
wcsnstr ⚠ - Search a wide string, up to n wide chars, for the first instance of a specific substring.
- SDL_
wcsstr ⚠ - Search a wide string for the first instance of a specific substring.
- SDL_
wcstol ⚠ - Parse a
long
from a wide string. - SDL_
zerop ⚠ - Clear an object’s memory to zero, using a pointer.
Type Aliases§
- SDL_
Compare Callback - A callback used with SDL sorting and binary search functions.
- SDL_
Compare Callback_ r - A callback used with SDL sorting and binary search functions.
- SDL_
Function Pointer - SDL_
Time - SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1, 1970).
- SDL_
calloc_ func - A callback used to implement
SDL_calloc()
. - SDL_
free_ func - A callback used to implement
SDL_free()
. - SDL_
iconv_ t - An opaque handle representing string encoding conversion state.
- SDL_
malloc_ func - A callback used to implement
SDL_malloc()
. - SDL_
realloc_ func - A callback used to implement
SDL_realloc()
. - Sint8
- A signed 8-bit integer type.
- Sint16
- A signed 16-bit integer type.
- Sint32
- A signed 32-bit integer type.
- Sint64
- A signed 64-bit integer type.
- Uint8
- An unsigned 8-bit integer type.
- Uint16
- An unsigned 16-bit integer type.
- Uint32
- An unsigned 32-bit integer type.
- Uint64
- An unsigned 64-bit integer type.