Skip to content

Commit

Permalink
Merge pull request #112 from CarterLi/master
Browse files Browse the repository at this point in the history
Detect static assertion support
  • Loading branch information
vitaut committed Feb 15, 2015
2 parents 0fc15d4 + 9fd5664 commit 829cd70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ endif ()
# add_definitions(-DFMT_USE_DELETED_FUNCTIONS=1)
#endif ()

#check_cxx_source_compiles("
# static_assert(true, \"\");
# int main(){}" FMT_STATIC_ASSERT)
#if (FMT_STATIC_ASSERT)
# add_definitions(-DFMT_USE_STATIC_ASSERT=1)
#endif ()

# GTest doesn't detect <tuple> with clang.
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1)
Expand Down
11 changes: 7 additions & 4 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
// many valid cases.
# pragma GCC diagnostic ignored "-Wshadow"
# endif
# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
# define FMT_HAS_GXX_CXX11 1
# endif
#else
# define FMT_GCC_EXTENSION
#endif
Expand Down Expand Up @@ -92,7 +95,7 @@
// since version 2013.
# define FMT_USE_VARIADIC_TEMPLATES \
(FMT_HAS_FEATURE(cxx_variadic_templates) || \
(FMT_GCC_VERSION >= 404 && __cplusplus >= 201103) || _MSC_VER >= 1800)
(FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800)
#endif

#ifndef FMT_USE_RVALUE_REFERENCES
Expand All @@ -103,7 +106,7 @@
# else
# define FMT_USE_RVALUE_REFERENCES \
(FMT_HAS_FEATURE(cxx_rvalue_references) || \
(FMT_GCC_VERSION >= 403 && __cplusplus >= 201103) || _MSC_VER >= 1600)
(FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600)
# endif
#endif

Expand All @@ -113,7 +116,7 @@

// Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature).
#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \
(FMT_GCC_VERSION >= 408 && __cplusplus >= 201103)
(FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11)
# define FMT_NOEXCEPT noexcept
#else
# define FMT_NOEXCEPT throw()
Expand All @@ -122,7 +125,7 @@
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions) || \
(FMT_GCC_VERSION >= 404 && __cplusplus >= 201103L) || _MSC_VER >= 1800
(FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800
# define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
TypeName& operator=(const TypeName&) = delete
Expand Down
3 changes: 2 additions & 1 deletion posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
# define FMT_UNUSED
#endif

#if FMT_USE_STATIC_ASSERT
#if FMT_USE_STATIC_ASSERT || FMT_HAS_CPP_ATTRIBUTE(cxx_static_assert) || \
(FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600
# define FMT_STATIC_ASSERT(cond, message) static_assert(cond, message)
#else
# define FMT_CONCAT_(a, b) FMT_CONCAT(a, b)
Expand Down

0 comments on commit 829cd70

Please sign in to comment.