Richard, you are right about the problem with the void pointer casting. I'm aware of it and already had to patch a few headers.
However my question above is not about void pointers at all. If you check the compiler error message, you will see that it is complaining about atomic_cmpxchg_int function. It appears in several core files and in auth module: https://github.com/search?q=repo%3Akamailio%2Fkamailio%20atomic_cmpxchg_int&type=code. I also want to reiterate that while compiling exactly the same C++ module with GCC I do not get this error. It appears only when switching to Clang.
For example, this function is used in this header https://github.com/kamailio/kamailio/blob/db8258bf9ab7ca772923d237f40fce4381dbcde4/src/core/atomic/atomic_x86.h#L256 but there are no other includes that might be pulling it in. This makes me think that it might be some sort of GCC built-in function, but internet seems to know nothing about it. The closest thing to it that I could find is GCC's __atomic_comare_exchange (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html), although the signature differs quite a bit.
So, does anyone here know where is this function implemented?
It's coming from src/core/atomic/atomic_x86.h (assuming you're on x86) and is defined via the macro ATOMIC_FUNC_CMPXCHG(), which creates type-specific inline functions implementing the CAS operation.
https://github.com/kamailio/kamailio/blob/db8258bf9ab7ca772923d237f40fce4381dbcde4/src/core/atomic/atomic_x86.h#L224
https://github.com/kamailio/kamailio/blob/db8258bf9ab7ca772923d237f40fce4381dbcde4/src/core/atomic/atomic_x86.h#L191
So you end with the prototype `inline static int atomic_cmpxchg_int(volatile int *. int, int)`.
The code in question from timer.h calls this with a void* argument.
Under C++ this is invalid (void* is not equivalent to int*) and results in an error.
Change it to an int* cast and it should work.
Cheers