Does cling using clang which version is too old? this make conflict with boost library


_ROOT Version:6.22.00
_Platform:mac os X
homebrew version


using the code

#include <boost/property_tree/json_parser.hpp>

get errors

/usr/local/include/boost/smart_ptr/shared_ptr.hpp:1072:31: error: expected expression
template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_SP_NOEXCEPT
                              ^
/private/tmp/root-20200623-39542-1b311gs/root-6.22.00/builddir/etc/cling/lib/clang/5.0.0/include/stdatomic.h:83:73: note: expanded from macro 'atomic_is_lock_free'
#define atomic_is_lock_free(obj) __c11_atomic_is_lock_free(sizeof(*(obj)))

What other headers have you included in the file you’re compiling?

<stdatomic.h> is getting included at some point. This is a C header, which gives you atomic_is_lock_free in the global namespace, as defined in the C standard. Evidently this is implemented in clang as a macro which is why you get that particular error message.

You’re writing C++ code, which means you should be using <atomic> which is the C++ header. This would give you std::atomic_is_lock_free in the std namespace, and you wouldn’t have a problem.

other headers boost lib
#include<boost/property_tree/json_parser.hpp>

Did you mean that the cling/clang using C header, while the boost library using the C++ header?

Clearly you have a macro that’s including <boost/property_tree/json_parser.hpp>. What other headers are you including? I mean all headers, including standard library ones.

Did you mean that the cling/clang using C header, while the boost library using the C++ header?

No, I think some piece of your code is including the C header in C++ code.

That’s why I’m confuse. The simple code cause errors

R__ADD_INCLUDE_PATH(/usr/local/include/)
#include<boost/property_tree/json_parser.hpp>
void p1_test(){}

Can you tell me what your boost version is? It’s what BOOST_LIB_VERSION in boost/version.hpp expands to.

boost version BOOST_VERSION 107200

So it’s not that then. Can you open a ROOT prompt and see what happens if you type in atomic_is_lock_free(2)? That’ll tell us if <stdatomic.h> is included in a startup file or something.

output

ROOT_prompt_0:1:1: error: indirection requires pointer operand ('int' invalid)
atomic_is_lock_free(2)
^~~~~~~~~~~~~~~~~~~~~~
/private/tmp/root-20200623-39542-1b311gs/root-6.22.00/builddir/etc/cling/lib/clang/5.0.0/include/stdatomic.h:83:67: note: expanded from macro 'atomic_is_lock_free'
#define atomic_is_lock_free(obj) __c11_atomic_is_lock_free(sizeof(*(obj)))

That’s why I thought the clang version is too old

The clang version isn’t too old (well, it is and this causes other issues if you use std::variant, but it’s not what’s causing this problem).

It seems ROOT is automatically including <stdatomic.h> when it should be including <atomic>. This may be because you have #include <stdatomic.h> in a startup file (like .rootlogon.C), or it’s a configuration issue with the way you built ROOT.

I’ve test it without .rootlogon.C file.
I thought the homebrew version of root is built with <stdatomic.h>
how could I change way of building ROOT to not to include <stdatomic.h>?

Someone familiar with Homebrew ROOT will need to help you with that, I only use ROOT on Linux.

Hi, I saw my name mentioned, but I think @beojan is spot-on with the explanation.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

FYI, this has been solved in ROOT 6.24/02 and later.