So, im programming in C89, and its going well so far except one issue, Im doing multithreaded applications and I need to use atomic.
I dont want to switch to C11 because I want my code to be compatable on every compiler and system and for my code to last a very long time.
Iv'e searched through stackoverflow for an existing question on this topic but didn't find any questions.
Does anyone know how to use the Atomic in C89. Say I have two threads using a bool
#include <stdatomic.h>
_Atomic bool theBool = false;
void funFromThirstThread()
{
theBool = true;
}
void funFromSecondThread() /*gets called repeatedly*/
{
if(theBool)
{
/*Do something*/
}
}
The above code is what I would do in C11, using the atomic in that, but how would I do this in C89? Can this be done? Preferably without volatile and locks thanks.