From: Martin Quinson Date: Wed, 9 Mar 2016 09:28:15 +0000 (+0100) Subject: Warn on undefined #if, and enjoy that feature X-Git-Tag: v3_13~453^2~22 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/79f947c54111b76b2db108fade4d8e4c0e4e703f Warn on undefined #if, and enjoy that feature - remove the #include from xbt/base.h now that it's safe - Add the include where needed. Amusingly, xbt/string.hpp was unable of getting the definition of HAVE_MC alone. Fixing this leaves me with only 2 broken tests in MC mode where I had 17 of them before... --- diff --git a/include/xbt/base.h b/include/xbt/base.h index d042d98d86..9d4ea07042 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -9,8 +9,6 @@ #ifndef XBT_BASE_H #define XBT_BASE_H -#include "simgrid_config.h" - /* Define _GNU_SOURCE for getline, isfinite, etc. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE diff --git a/include/xbt/signal.hpp b/include/xbt/signal.hpp index 714ae0d17d..26bd2df57f 100644 --- a/include/xbt/signal.hpp +++ b/include/xbt/signal.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_XBT_SIGNAL_HPP #define SIMGRID_XBT_SIGNAL_HPP +#include "simgrid_config.h" #if SIMGRID_HAVE_LIBSIG #include #else diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index 71f75458fc..633162a1f2 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -7,6 +7,7 @@ #ifndef SIMGRIC_XBT_STRING_HPP #define SIMGRIC_XBT_STRING_HPP +#include "src/internal_config.h" #if HAVE_MC #include diff --git a/src/xbt/xbt_os_file.c b/src/xbt/xbt_os_file.c index 2dda1b24bb..be781e16aa 100644 --- a/src/xbt/xbt_os_file.c +++ b/src/xbt/xbt_os_file.c @@ -67,7 +67,7 @@ ssize_t xbt_getline(char **buf, size_t *n, FILE *stream) * The argument is never modified, and the returned value must be freed after use. */ char *xbt_dirname(const char *path) { -#if _MSC_VER +#ifdef _MSC_VER char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; errno_t err; @@ -85,7 +85,7 @@ char *xbt_dirname(const char *path) { * The argument is never modified, and the returned value must be freed after use. */ char *xbt_basename(const char *path) { -#if _MSC_VER +#ifdef _MSC_VER char file[1024]; char ext[1024]; errno_t err; diff --git a/tools/cmake/GCCFlags.cmake b/tools/cmake/GCCFlags.cmake index 31c50d7cf4..b1ecbda46d 100644 --- a/tools/cmake/GCCFlags.cmake +++ b/tools/cmake/GCCFlags.cmake @@ -15,12 +15,12 @@ set(optCFLAGS "") if(enable_compile_warnings) - set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ") + set(warnCFLAGS "-fno-common -Wall -Wundef -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ") if(CMAKE_COMPILER_IS_GNUCC) set(warnCFLAGS "${warnCFLAGS}-Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror") if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs") endif()