Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような操作をアトミックに行う gcc 拡張機能はありますか
a = b++ in C. ミューテックスの使用は、そのような簡単な操作にはやり過ぎのようです。
拡張機能を使用する必要はありません。使用するだけ<stdatomic.h>です:
<stdatomic.h>
#include <stdatomic.h> atomic_store(&a, atomic_fetch_add(&b, 1));