Skip to content

Commit

Permalink
fix gcc compile error w. stricter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mlund committed Dec 31, 2018
1 parent b229d09 commit 7904708
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (ENABLE_MPI)
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_CXX_LINK_FLAGS})
endif ()
set(LINKLIBS ${LINKLIBS} ${MPI_CXX_LIBRARIES})
include_directories(${MPI_CXX_INCLUDE_PATH})
include_directories(SYSTEM ${MPI_CXX_INCLUDE_PATH})
add_definitions(-DENABLE_MPI)
endif ()
endif ()
Expand Down Expand Up @@ -165,7 +165,7 @@ ExternalProject_Get_Property(doctest source_dir)
set(DocTestIncludeDir ${source_dir}/../../src/)

add_definitions(-DDOCTEST_CONFIG_DISABLE)
include_directories(${EigenIncludeDir} ${DocTestIncludeDir} ${JSONIncludeDir} ${RangeV3IncludeDir}
include_directories(SYSTEM ${EigenIncludeDir} ${DocTestIncludeDir} ${JSONIncludeDir} ${RangeV3IncludeDir}
${Pybind11IncludeDir} ${DocoptIncludeDir} ${XdrfileIncludeDir} ${ProgressIncludeDir})

# POWERSASA
Expand All @@ -179,7 +179,7 @@ if (ENABLE_POWERSASA)
endif ()
endforeach ()
add_definitions("-DENABLE_POWERSASA")
include_directories("${CMAKE_SOURCE_DIR}/include/faunus/sasa")
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/include/faunus/sasa")
endif ()

# GIT
Expand Down Expand Up @@ -244,13 +244,17 @@ set(hdrs
${CMAKE_SOURCE_DIR}/src/units.h
)

add_compile_options(
-Wall
-Wextra
-pedantic-errors
-Wno-sign-compare
-Wno-unused-local-typedef
-Wno-unknown-pragmas)
# Compiler spacific flagg

## GCC
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -pedantic-errors -Werror -Wunreachable-code
-Wno-sign-compare -Wno-unused-local-typedefs -Wno-unknown-pragmas)
## Clang
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -pedantic-errors -Werror -Wunreachable-code
-Wstrict-aliasing -Wno-sign-compare -Wno-unused-local-typedef -Wno-unknown-pragmas)
endif()

add_library(libfaunus STATIC ${objs} ${hdrs})
add_dependencies(libfaunus modernjson doctest eigen range-v3 docopt xdrfile progressbar pybind11)
Expand Down
2 changes: 1 addition & 1 deletion src/auxiliary.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace Faunus
typedef std::int32_t Tint;
static_assert(2 * sizeof(Tint) == sizeof(double),
"Approximate exp() requires 4-byte integer");
double d;
double d(0);
*((Tint *) (&d) + 0) = 0;
*((Tint *) (&d) + 1) = (Tint) (1512775 * y + 1072632447);
return d;
Expand Down
4 changes: 2 additions & 2 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include <Eigen/Geometry>
#include <json.hpp>
#include <range/v3/all.hpp>
#include "random.h"

#ifdef DOCTEST_LIBRARY_INCLUDED
#include "units.h"
#endif
#include "random.h"

// Eigen<->JSON (de)serialization
namespace Eigen {
Expand All @@ -40,7 +40,7 @@ namespace Eigen {
}
throw std::runtime_error("JSON->Eigen conversion error");
}
};
}

/** @brief Faunus main namespace */
namespace Faunus {
Expand Down
4 changes: 4 additions & 0 deletions src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace Faunus {
case SLIT: return len.x()*len.y()*len.z() / pbc_disable;
case CYLINDER: return pc::pi*radius*radius*len.z();
}
assert(false);
return 0;
}

Point Chameleon::setVolume(double V, VolumeMethod method) {
Expand Down Expand Up @@ -130,6 +132,8 @@ namespace Faunus {
case SPHERE: return {2*radius,2*radius,2*radius};
case CYLINDER: return {2*radius,2*radius,len.z()};
}
assert(false);
return Point();
} //!< Enscribe geometry in cuboid

void Chameleon::randompos(Point &m, Random &rand) const {
Expand Down

0 comments on commit 7904708

Please sign in to comment.