GLIB: g_atomic_int_get becomes NO-OP?
问题 In a larger piece of code, I noticed that the g_atomic_* functions in glib were not doing what I expected, so I wrote this simple example: #include <stdlib.h> #include "glib.h" #include "pthread.h" #include "stdio.h" void *set_foo(void *ptr) { g_atomic_int_set(((int*)ptr), 42); return NULL; } int main(void) { int foo = 0; pthread_t other; if (pthread_create(&other, NULL, set_foo, &foo)== 0) { pthread_join(other, NULL); printf("Got %d\n", g_atomic_int_get(&foo)); } else { printf("Thread did