GithubHelp home page GithubHelp logo

how to compile with clang ? about libpmemobj-cpp HOT 5 CLOSED

pmem avatar pmem commented on July 20, 2024
how to compile with clang ?

from libpmemobj-cpp.

Comments (5)

szyrom avatar szyrom commented on July 20, 2024

Hi,
thanks for this catch. clang 3.6 does not fully support all C++11 features (traits in this case).
It should work with this PR #325 (will be merged after code review).

from libpmemobj-cpp.

igchor avatar igchor commented on July 20, 2024

@freboat I strongly recommend to upgrade your compiler, this should fix the issue. However, if you want to use clang 3.6 you can wait until #325 is merged or apply the following patch :

---
 include/libpmemobj++/detail/common.hpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/libpmemobj++/detail/common.hpp b/include/libpmemobj++/detail/common.hpp
index d570464..aba2063 100644
--- a/include/libpmemobj++/detail/common.hpp
+++ b/include/libpmemobj++/detail/common.hpp
@@ -95,7 +95,15 @@
  * and 0 in gcc. It means that for gcc < 5 IS_TRIVIALLY_COPYABLE is more
  * restrictive than is_trivially_copyable.
  */
+#if !defined(LIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY)
 #if !defined(__clang__) && defined(__GNUG__) && __GNUC__ < 5
+#define LIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY 1
+#else
+#define LIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY 0
+#endif
+#endif
+
+#if LIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY
 #define IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
 #else
 #define IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
-- 

After that, to compile libpmemobj-cpp tests and examples with your clang version please run cmake with: -DCMAKE_CXX_FLAGS=-DLIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY=1. If you want to compile your application with libmemobj-cpp using clang 3.6 you must set LIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY=1 in your code or during compilation.

from libpmemobj-cpp.

freboat avatar freboat commented on July 20, 2024

@szyrom & @igchor thanks for your kind reply,
i updated clang to 3.9 run cmake with -DCMAKE_CXX_FLAGS=-DLIBPMEMOBJ_CPP_USE_HAS_TRIVIAL_COPY=1
but got another error:

In file included from /home/brook/pmem/libpmemobj-cpp/tests/string_exceptions/string_exceptions.cpp:35:
/home/brook/pmem/libpmemobj-cpp/include/libpmemobj++/experimental/slice.hpp:79:15: error: no member named 'out_of_range' in namespace
'std'
throw std::out_of_range("pmem::obj::slice");
~~~~~^
/home/brook/pmem/libpmemobj-cpp/include/libpmemobj++/experimental/slice.hpp:137:15: error: no member named 'out_of_range' in namespace
'std'
throw std::out_of_range("pmem::obj::slice");
~~~~~^

from libpmemobj-cpp.

freboat avatar freboat commented on July 20, 2024

@ALL, i have fixed the error,
include/libpmemobj++/experimental/slice.hpp lost the stdexcept headfile, just add and it works:

#include <stdexcept>

from libpmemobj-cpp.

szyrom avatar szyrom commented on July 20, 2024

@freboat Will you submit pull request? Your contribution is more than welcome :)

from libpmemobj-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.