Is SDL_GetError thread safe or not?

The code for SDL_GetErrorMsg implies that it’s supposed to be thread safe to work with, but SDL_GetError calls that with a pointer into a static char buffer. And I think that’s just a global static buffer, not a thread local buffer? I’m not a C expert, so I could be totally off base.

Basically, is the error stuff thread safe? If I send my audio processing to another thread and it causes an error, will writing that error potentially cause a data race? Can I read the error from the audio thread? Or should it somehow signal to the main thread that the main thread should go check the error and just hope that no one else has caused an error in the mean time?

1 Like