stdinc topic

CategoryStdinc

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().

Functions

sdlAbs(int x) int stdinc
Compute the absolute value of x.
sdlAcos(double x) double stdinc
Compute the arc cosine of x.
sdlAcosf(double x) double stdinc
Compute the arc cosine of x.
sdlAlignedAlloc(int alignment, int size) Pointer<NativeType> stdinc
Allocate memory aligned to a specific alignment.
sdlAlignedFree(Pointer<NativeType> mem) → void stdinc
Free memory allocated by SDL_aligned_alloc().
sdlAsin(double x) double stdinc
Compute the arc sine of x.
sdlAsinf(double x) double stdinc
Compute the arc sine of x.
sdlAsprintf(Pointer<Pointer<Int8>> strp, String? fmt) int stdinc
This works exactly like asprintf() but doesn't require access to a C runtime.
sdlAtan(double x) double stdinc
Compute the arc tangent of x.
sdlAtan2(double y, double x) double stdinc
Compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant.
sdlAtan2f(double y, double x) double stdinc
Compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant.
sdlAtanf(double x) double stdinc
Compute the arc tangent of x.
sdlAtof(String? str) double stdinc
Parse a double from a string.
sdlAtoi(String? str) int stdinc
Parse an int from a string.
sdlBsearch(Pointer<NativeType> key, Pointer<NativeType> base, int nmemb, int size, Pointer<NativeFunction<SdlCompareCallback>> compare) Pointer<NativeType> stdinc
Perform a binary search on a previously sorted array.
sdlBsearchR(Pointer<NativeType> key, Pointer<NativeType> base, int nmemb, int size, Pointer<NativeFunction<SdlCompareCallbackR>> compare, Pointer<NativeType> userdata) Pointer<NativeType> stdinc
Perform a binary search on a previously sorted array, passing a userdata pointer to the compare function.
sdlCeil(double x) double stdinc
Compute the ceiling of x.
sdlCeilf(double x) double stdinc
Compute the ceiling of x.
sdlCopysign(double x, double y) double stdinc
Copy the sign of one floating-point value to another.
sdlCopysignf(double x, double y) double stdinc
Copy the sign of one floating-point value to another.
sdlCos(double x) double stdinc
Compute the cosine of x.
sdlCosf(double x) double stdinc
Compute the cosine of x.
sdlCrc16(int crc, Pointer<NativeType> data, int len) int stdinc
Calculate a CRC-16 value.
sdlCrc32(int crc, Pointer<NativeType> data, int len) int stdinc
Calculate a CRC-32 value.
sdlCreateEnvironment(bool populated) Pointer<SdlEnvironment> stdinc
Create a set of environment variables
sdlDestroyEnvironment(Pointer<SdlEnvironment> env) → void stdinc
Destroy a set of environment variables.
sdlExp(double x) double stdinc
Compute the exponential of x.
sdlExpf(double x) double stdinc
Compute the exponential of x.
sdlFabs(double x) double stdinc
Compute the absolute value of x
sdlFabsf(double x) double stdinc
Compute the absolute value of x
sdlFloor(double x) double stdinc
Compute the floor of x.
sdlFloorf(double x) double stdinc
Compute the floor of x.
sdlFmod(double x, double y) double stdinc
Return the floating-point remainder of x / y
sdlFmodf(double x, double y) double stdinc
Return the floating-point remainder of x / y
sdlFree(Pointer<NativeType> mem) → void stdinc
Free allocated memory.
sdlGetenv(String? name) String? stdinc
Get the value of a variable in the environment.
sdlGetEnvironment() Pointer<SdlEnvironment> stdinc
Get the process environment.
sdlGetEnvironmentVariable(Pointer<SdlEnvironment> env, String? name) String? stdinc
Get the value of a variable in the environment.
sdlGetEnvironmentVariables(Pointer<SdlEnvironment> env) Pointer<Pointer<Int8>> stdinc
Get all variables in the environment.
sdlGetenvUnsafe(String? name) String? stdinc
Get the value of a variable in the environment.
sdlGetMemoryFunctions(Pointer<Pointer<NativeFunction<SdlMallocFunc>>> mallocFunc, Pointer<Pointer<NativeFunction<SdlCallocFunc>>> callocFunc, Pointer<Pointer<NativeFunction<SdlReallocFunc>>> reallocFunc, Pointer<Pointer<NativeFunction<SdlFreeFunc>>> freeFunc) → void stdinc
Get the current set of SDL memory functions.
sdlGetNumAllocations() int stdinc
Get the number of outstanding (unfreed) allocations.
sdlGetOriginalMemoryFunctions(Pointer<Pointer<NativeFunction<SdlMallocFunc>>> mallocFunc, Pointer<Pointer<NativeFunction<SdlCallocFunc>>> callocFunc, Pointer<Pointer<NativeFunction<SdlReallocFunc>>> reallocFunc, Pointer<Pointer<NativeFunction<SdlFreeFunc>>> freeFunc) → void stdinc
Get the original set of SDL memory functions.
sdlIconv(Pointer<SdlIconvT> cd, Pointer<Pointer<Int8>> inbuf, Pointer<Uint32> inbytesleft, Pointer<Pointer<Int8>> outbuf, Pointer<Uint32> outbytesleft) int stdinc
This function converts text between encodings, reading from and writing to a buffer.
sdlIconvClose(Pointer<SdlIconvT> cd) int stdinc
This function frees a context used for character set conversion.
sdlIconvOpen(String? tocode, String? fromcode) Pointer<SdlIconvT> stdinc
This function allocates a context for the specified character set conversion.
sdlIconvString(String? tocode, String? fromcode, String? inbuf, int inbytesleft) Pointer<Int8> stdinc
Helper function to convert a string's encoding in one call.
sdlIsalnum(int x) int stdinc
Query if a character is alphabetic (a letter) or a number.
sdlIsalpha(int x) int stdinc
Query if a character is alphabetic (a letter).
sdlIsblank(int x) int stdinc
Report if a character is blank (a space or tab).
sdlIscntrl(int x) int stdinc
Report if a character is a control character.
sdlIsdigit(int x) int stdinc
Report if a character is a numeric digit.
sdlIsgraph(int x) int stdinc
Report if a character is any "printable" except space.
sdlIsinf(double x) int stdinc
Return whether the value is infinity.
sdlIsinff(double x) int stdinc
Return whether the value is infinity.
sdlIslower(int x) int stdinc
Report if a character is lower case.
sdlIsnan(double x) int stdinc
Return whether the value is NaN.
sdlIsnanf(double x) int stdinc
Return whether the value is NaN.
sdlIsprint(int x) int stdinc
Report if a character is "printable".
sdlIspunct(int x) int stdinc
Report if a character is a punctuation mark.
sdlIsspace(int x) int stdinc
Report if a character is whitespace.
sdlIsupper(int x) int stdinc
Report if a character is upper case.
sdlIsxdigit(int x) int stdinc
Report if a character is a hexadecimal digit.
sdlItoa(int value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert an integer into a string.
sdlLltoa(Pointer<NativeType> value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert a long long integer into a string.
sdlLog10(double x) double stdinc
Compute the base-10 logarithm of x.
sdlLog10f(double x) double stdinc
Compute the base-10 logarithm of x.
sdlLogf(double x) double stdinc
Compute the natural logarithm of x.
sdlLround(double x) int stdinc
Round x to the nearest integer representable as a long
sdlLroundf(double x) int stdinc
Round x to the nearest integer representable as a long
sdlLtoa(int value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert a long integer into a string.
sdlMalloc(int size) Pointer<NativeType> stdinc
Allocate uninitialized memory.
sdlMemcmp(Pointer<NativeType> s1, Pointer<NativeType> s2, int len) int stdinc
Compare two buffers of memory.
sdlMemcpy(Pointer<NativeType> arg0, Pointer<NativeType> arg1, int len) Pointer<NativeType> stdinc
Copy non-overlapping memory.
sdlMemmove(Pointer<NativeType> arg0, Pointer<NativeType> arg1, int len) Pointer<NativeType> stdinc
Copy memory ranges that might overlap.
sdlMemset(Pointer<NativeType> arg0, int c, int len) Pointer<NativeType> stdinc
Initialize all bytes of buffer of memory to a specific value.
sdlMemset4(Pointer<NativeType> dst, int val, int dwords) Pointer<NativeType> stdinc
Initialize all 32-bit words of buffer of memory to a specific value.
sdlModf(double x, Pointer<Double> y) double stdinc
Split x into integer and fractional parts
sdlModff(double x, Pointer<Float> y) double stdinc
Split x into integer and fractional parts
sdlMurmur332(Pointer<NativeType> data, int len, int seed) int stdinc
Calculate a 32-bit MurmurHash3 value for a block of data.
sdlPow(double x, double y) double stdinc
Raise x to the power y
sdlPowf(double x, double y) double stdinc
Raise x to the power y
sdlQsort(Pointer<NativeType> base, int nmemb, int size, Pointer<NativeFunction<SdlCompareCallback>> compare) → void stdinc
Sort an array.
sdlQsortR(Pointer<NativeType> base, int nmemb, int size, Pointer<NativeFunction<SdlCompareCallbackR>> compare, Pointer<NativeType> userdata) → void stdinc
Sort an array, passing a userdata pointer to the compare function.
sdlRand(int n) int stdinc
Generate a pseudo-random number less than n for positive n
sdlRandBits() int stdinc
Generate 32 pseudo-random bits.
sdlRandBitsR(Pointer<Uint64> state) int stdinc
Generate 32 pseudo-random bits.
sdlRandf() double stdinc
Generate a uniform pseudo-random floating point number less than 1.0
sdlRandfR(Pointer<Uint64> state) double stdinc
Generate a uniform pseudo-random floating point number less than 1.0
sdlRandR(Pointer<Uint64> state, int n) int stdinc
Generate a pseudo-random number less than n for positive n
sdlRound(double x) double stdinc
Round x to the nearest integer.
sdlRoundf(double x) double stdinc
Round x to the nearest integer.
sdlScalbn(double x, int n) double stdinc
Scale x by an integer power of two.
sdlScalbnf(double x, int n) double stdinc
Scale x by an integer power of two.
sdlSetEnvironmentVariable(Pointer<SdlEnvironment> env, String? name, String? value, bool overwrite) bool stdinc
Set the value of a variable in the environment.
sdlSetenvUnsafe(String? name, String? value, int overwrite) int stdinc
Set the value of a variable in the environment.
sdlSetMemoryFunctions(Pointer<NativeFunction<SdlMallocFunc>> mallocFunc, Pointer<NativeFunction<SdlCallocFunc>> callocFunc, Pointer<NativeFunction<SdlReallocFunc>> reallocFunc, Pointer<NativeFunction<SdlFreeFunc>> freeFunc) bool stdinc
Replace SDL's memory allocation functions with a custom set.
sdlSin(double x) double stdinc
Compute the sine of x.
sdlSinf(double x) double stdinc
Compute the sine of x.
sdlSnprintf(Pointer<Int8> text, int maxlen, String? fmt) int stdinc
This works exactly like snprintf() but doesn't require access to a C runtime.
sdlSqrt(double x) double stdinc
Compute the square root of x.
sdlSqrtf(double x) double stdinc
Compute the square root of x.
sdlSrand(int seed) → void stdinc
Seeds the pseudo-random number generator.
sdlSscanf(String? text, String? fmt) int stdinc
This works exactly like sscanf() but doesn't require access to a C runtime.
sdlStepBackUtf8(String? start, Pointer<Pointer<Int8>> pstr) int stdinc
Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
sdlStepUtf8(Pointer<Pointer<Int8>> pstr, Pointer<Uint32> pslen) int stdinc
Decode a UTF-8 string, one Unicode codepoint at a time.
sdlStrcasecmp(String? str1, String? str2) int stdinc
Compare two null-terminated UTF-8 strings, case-insensitively.
sdlStrcasestr(String? haystack, String? needle) Pointer<Int8> stdinc
Search a UTF-8 string for the first instance of a specific substring, case-insensitively.
sdlStrchr(String? str, int c) Pointer<Int8> stdinc
Search a string for the first instance of a specific byte.
sdlStrcmp(String? str1, String? str2) int stdinc
Compare two null-terminated UTF-8 strings.
sdlStrdup(String? str) Pointer<Int8> stdinc
Allocate a copy of a string.
sdlStrlcat(Pointer<NativeType> arg0, String? src, int maxlen) int stdinc
Concatenate strings.
sdlStrlcpy(Pointer<Int8> dst, String? src, int maxlen) int stdinc
Copy a string.
sdlStrlen(String? str) int stdinc
This works exactly like strlen() but doesn't require access to a C runtime.
sdlStrlwr(Pointer<Int8> str) Pointer<Int8> stdinc
Convert a string to lowercase.
sdlStrncasecmp(String? str1, String? str2, int maxlen) int stdinc
Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
sdlStrncmp(String? str1, String? str2, int maxlen) int stdinc
Compare two UTF-8 strings up to a number of bytes.
sdlStrndup(String? str, int maxlen) Pointer<Int8> stdinc
Allocate a copy of a string, up to n characters.
sdlStrnlen(String? str, int maxlen) int stdinc
This works exactly like strnlen() but doesn't require access to a C runtime.
sdlStrnstr(String? haystack, String? needle, int maxlen) Pointer<Int8> stdinc
Search a string, up to n bytes, for the first instance of a specific substring.
sdlStrpbrk(String? str, String? breakset) Pointer<Int8> stdinc
Searches a string for the first occurrence of any character contained in a breakset, and returns a pointer from the string to that character.
sdlStrrchr(String? str, int c) Pointer<Int8> stdinc
Search a string for the last instance of a specific byte.
sdlStrrev(Pointer<Int8> str) Pointer<Int8> stdinc
Reverse a string's contents.
sdlStrstr(String? haystack, String? needle) Pointer<Int8> stdinc
Search a string for the first instance of a specific substring.
sdlStrtod(String? str, Pointer<Pointer<Int8>> endp) double stdinc
Parse a double from a string.
sdlStrtokR(Pointer<Int8> str, String? delim, Pointer<Pointer<Int8>> saveptr) Pointer<Int8> stdinc
This works exactly like strtok_r() but doesn't require access to a C runtime.
sdlStrtol(String? str, Pointer<Pointer<Int8>> endp, int base) int stdinc
Parse a long from a string.
sdlStrtoll(String? str, Pointer<Pointer<Int8>> endp, int base) Pointer<NativeType> stdinc
Parse a long long from a string.
sdlStrtoul(String? str, Pointer<Pointer<Int8>> endp, int base) int stdinc
Parse an unsigned long from a string.
sdlStrtoull(String? str, Pointer<Pointer<Int8>> endp, int base) Pointer<NativeType> stdinc
Parse an unsigned long long from a string.
sdlStrupr(Pointer<Int8> str) Pointer<Int8> stdinc
Convert a string to uppercase.
sdlSwprintf(Pointer<Int16> text, int maxlen, Pointer<Int16> fmt) int stdinc
This works exactly like swprintf() but doesn't require access to a C runtime.
sdlTan(double x) double stdinc
Compute the tangent of x.
sdlTanf(double x) double stdinc
Compute the tangent of x.
sdlTolower(int x) int stdinc
Convert low-ASCII English letters to lowercase.
sdlToupper(int x) int stdinc
Convert low-ASCII English letters to uppercase.
sdlTrunc(double x) double stdinc
Truncate x to an integer.
sdlTruncf(double x) double stdinc
Truncate x to an integer.
sdlUcs4ToUtf8(int codepoint, Pointer<Int8> dst) Pointer<Int8> stdinc
Convert a single Unicode codepoint to UTF-8.
sdlUitoa(int value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert an unsigned integer into a string.
sdlUlltoa(Pointer<NativeType> value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert an unsigned long long integer into a string.
sdlUltoa(int value, Pointer<Int8> str, int radix) Pointer<Int8> stdinc
Convert an unsigned long integer into a string.
sdlUnsetEnvironmentVariable(Pointer<SdlEnvironment> env, String? name) bool stdinc
Clear a variable from the environment.
sdlUnsetenvUnsafe(String? name) int stdinc
Clear a variable from the environment.
sdlUtf8strlcpy(Pointer<Int8> dst, String? src, int dstBytes) int stdinc
Copy an UTF-8 string.
sdlUtf8strlen(String? str) int stdinc
Count the number of codepoints in a UTF-8 string.
sdlUtf8strnlen(String? str, int bytes) int stdinc
Count the number of codepoints in a UTF-8 string, up to n bytes.
sdlVasprintf(Pointer<Pointer<Int8>> strp, String? fmt) int stdinc
This works exactly like vasprintf() but doesn't require access to a C runtime.
sdlVsnprintf(Pointer<Int8> text, int maxlen, String? fmt) int stdinc
This works exactly like vsnprintf() but doesn't require access to a C runtime.
sdlVsscanf(String? text, String? fmt) int stdinc
This works exactly like vsscanf() but doesn't require access to a C runtime.
sdlVswprintf(Pointer<Int16> text, int maxlen, Pointer<Int16> fmt) int stdinc
This works exactly like vswprintf() but doesn't require access to a C runtime.
sdlWcscasecmp(Pointer<Int16> str1, Pointer<Int16> str2) int stdinc
Compare two null-terminated wide strings, case-insensitively.
sdlWcscmp(Pointer<Int16> str1, Pointer<Int16> str2) int stdinc
Compare two null-terminated wide strings.
sdlWcsdup(Pointer<Int16> wstr) Pointer<Int16> stdinc
Allocate a copy of a wide string.
sdlWcslcat(Pointer<NativeType> arg0, Pointer<Int16> src, int maxlen) int stdinc
Concatenate wide strings.
sdlWcslcpy(Pointer<Int16> dst, Pointer<Int16> src, int maxlen) int stdinc
Copy a wide string.
sdlWcslen(Pointer<Int16> wstr) int stdinc
This works exactly like wcslen() but doesn't require access to a C runtime.
sdlWcsncasecmp(Pointer<Int16> str1, Pointer<Int16> str2, int maxlen) int stdinc
Compare two wide strings, case-insensitively, up to a number of wchar_t.
sdlWcsncmp(Pointer<Int16> str1, Pointer<Int16> str2, int maxlen) int stdinc
Compare two wide strings up to a number of wchar_t values.
sdlWcsnlen(Pointer<Int16> wstr, int maxlen) int stdinc
This works exactly like wcsnlen() but doesn't require access to a C runtime.
sdlWcsnstr(Pointer<Int16> haystack, Pointer<Int16> needle, int maxlen) Pointer<Int16> stdinc
Search a wide string, up to n wide chars, for the first instance of a specific substring.
sdlWcsstr(Pointer<Int16> haystack, Pointer<Int16> needle) Pointer<Int16> stdinc
Search a wide string for the first instance of a specific substring.
sdlWcstol(Pointer<Int16> str, Pointer<Pointer<Int16>> endp, int base) int stdinc
Parse a long from a wide string.