In C is equivalent to use atomic types without calling atomic_load, atomic_store or atomic_fetch_add but using the standard C syntax of non atomic variables.
These 2 pieces of codes are really equivalent and portable?
With atomic functions:
Code:
atomic_int var;
atomic_store(&var,10);
if (atomic_load(&var))
{
...
}
atomic_fetch_add(&var,1);
atomic_fetch_add(&var,10);
With standard syntax:
Code:
atomic_int var;
var=10;
if (var)
{
...
}
var++;
var+=10;
I've tried with compiler explorer and seemed the same but I want to be sure that the standard syntax is equivalent in calling the relative atomic functions and it is portable.