SDL_SCOPED_CAPABILITY(3)

✨ NAME ✨

SDL_SCOPED_CAPABILITY β€” it's a lil wrapper around the Clang thread safety analysis annotations, bestie πŸ’…

Like, that's the whole vibe. A wrapper. Around annotations. For thread safety. She's small but she's mighty.


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_mutex.h>

#define SDL_SCOPED_CAPABILITY \
  SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)

That's it. That's the whole thing. One macro, defined in terms of another macro, and she is serving. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. This macro is literally just a wrapper around the Clang thread safety analysis annotations, and if you wanna actually understand what's going on under the hood, the docs are right here:

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h

Go read it, bestie, it's giving ✨deep lore✨. No cap, the mutex section is where the real tea is. πŸ“

Note: this is a macro, not a function, so there's nothing to call and nothing to link. You just #include the header and let the macro do her little thing. 🧚

πŸ’– AVAILABILITY πŸ’–

She's been around since SDL 3.2.0, so if you're on anything older, that's a you problem, ngl. πŸ™ˆ


anyway bestie, that's the whole page β€” tiny, iconic, lowkey essential if you're doing concurrency and want Clang to yell at you before your threads do 😭πŸ”₯

πŸ’… mwah, go write some safe code πŸ’…


this cutie pie of a page comes to you from Simple Directmedia Layer πŸ’œ β€” SDL 3.4.18, and yes, she's page SDL_SCOPED_CAPABILITY(3). periodt. πŸ‘‘

πŸ“¦ where this page comes from