SDL_IN_BYTECAP(3)

πŸ’– SDL_IN_BYTECAP(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_IN_BYTECAP β€” a lil macro that annotates function params with input buffer size. no cap, that's literally all it does, and it's iconic for it. πŸŽ€


✨ NAME ✨

SDL_IN_BYTECAP β€” macro that annotates function params with input buffer size. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_IN_BYTECAP(x) _In_bytecount_(x)

copy that include exactly, bestie, character for character. πŸ’…


🫢 DESCRIPTION 🫢

so here's the tea. say we wanted to annotate memcpy, right? like this:

void *memcpy(void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);

what this is doing is noting that src should be len bytes in size, and that it's only read by the function. that's it, that's the note. πŸ“

and because that note is there, the compiler or other analysis tools can warn you when this doesn't appear to be the case. like a lil friend going "bestie… that buffer is NOT len bytes, I'm gonna need you to look at that". πŸ”βœ¨

and on compilers without this annotation mechanism? it's defined to nothing. fr fr, it just vanishes. poof. πŸ«₯ the code still compiles, the annotation just doesn't exist. no drama, no warnings, no vibe check.

⭐ AVAILABILITY ⭐

this macro is available since SDL 3.2.0. so if you're on something older, it's giving… not here yet. πŸ’€


and that's the whole page, periodt. thanks for reading, you ate. πŸ‘‘

signing off from the Simple Directmedia Layer besties β€” this was SDL 3.4.18, page SDL_IN_BYTECAP(3). mwah, take care of your buffers. πŸ’–πŸŒˆ

πŸ“¦ where this page comes from