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?
-- 
Ivan Ribakov
Software Engineer


On Sat, 29 Apr 2023 at 15:29, Richard Fuchs <rfuchs@sipwise.com> wrote:
On 28/04/2023 18.56, [EXT] Ivan Ribakov wrote:
Hi all,

I looked at Kamailio 5.6.3 makefiles and saw mention of clang being supported. Yet when I try to build it with clang (more precisely, I build a C++ module using clang that includes some Kamailio C headers via "extern C") I get following error:

In file included from /tmp/kamailio/kamailio/modules/tm/t_funcs.h:45:
/tmp/kamailio/kamailio/modules/tm/timer.h:204:2: error: no matching function for call to 'atomic_cmpxchg_int'

Any suggestions on how to overcome this error or any general suggestions for using Kamailio + clang?

That's not a problem of clang, but rather a problem of using C++. C++ doesn't play nice with the void* type and that's what's being used in that inlined function. You'd have the same problem with gcc.

You can either patch up timer.h and change the cast to int* (which it probably should be anyway), or pull in the header in a C source, and then link that from the rest of your C++ project.

Cheers

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-leave@lists.kamailio.org