the documentation GLib – 2.0 says that g_once_init_enter() and g_once_init_leave() should not be marked volatile. And, indeed, I get an incompatible pointer type warning if I declare the parameter variable as such. However, if I don’t use volatileit seems that the function does not do what it is supposed to be doing.
I am working on Tracker and I wanted to get to a warning-free build, thus I tried to remove the volatile from the declarations of g_once_init_enter() sentinel variables . However, when I do this, a lot of tests fail.
From what you’ve said, you are interpreting the documentation correctly (although I’d have to see a diff of what you’ve done to be sure). Previously, people (myself included) thought that volatile should be used to indicate a variable which is accessed atomically or by multiple threads, but that’s now understood to not be correct. volatile should basically never be used in C.