Skip to content

Commit

Permalink
add platform check for std::is_trivially_copyable
Browse files Browse the repository at this point in the history
 Yes, the template instantiation appears necessary for cmake to
 detect the type. If there's a better type for it than int, I'm
 open to suggestions.
  • Loading branch information
oldlaptop committed Apr 15, 2017
1 parent 8f76537 commit b8f1d76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmake/platformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include(CheckLibraryExists)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)

CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
Expand All @@ -16,6 +17,10 @@ CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)

set(CMAKE_EXTRA_INCLUDE_FILES "cstddef")
CHECK_TYPE_SIZE("std::max_align_t" STD_MAX_ALIGN_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "type_traits")
set(CMAKE_REQUIRED_FLAGS "-std=c++11") # required for g++ <= 5
CHECK_TYPE_SIZE("std::is_trivially_copyable<int>" STD_IS_TRIVIALLY_COPYABLE LANGUAGE CXX)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_EXTRA_INCLUDE_FILES)

CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
Expand Down
2 changes: 2 additions & 0 deletions cmake/platformChecks.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#cmakedefine HAVE_MAX_ALIGN_T
#cmakedefine HAVE_STD_MAX_ALIGN_T

#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE

#cmakedefine01 IS_64BIT

#cmakedefine01 HAVE_STRCASECMP
Expand Down
4 changes: 3 additions & 1 deletion code/scripting/ade.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define FS2_OPEN_ADE_H

#include "globalincs/pstypes.h"
#include "platformChecks.h"

extern "C" {
#include <lauxlib.h>
Expand Down Expand Up @@ -226,8 +227,9 @@ template<class StoreType>
class ade_obj: public ade_lib_handle {
public:
// Make sure that the stored type is compatible with our requirements
#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
static_assert(std::is_trivially_copyable<StoreType>::value, "ADE object types must be trivially copyable!");

#endif
ade_obj(const char* in_name, const char* in_desc, const ade_lib_handle* in_deriv = NULL) {
ade_table_entry ate;

Expand Down

0 comments on commit b8f1d76

Please sign in to comment.