[mlpack-git] master: Check arma_config.hpp when compiling with mlpack. This is for downstream users, not for during the build of mlpack. (857328f)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Apr 1 19:11:45 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/60010cad2a8c3e3f52f69c10d8077a025255d6db...857328f4a18658ee7e1fe9af96456274ec415355

>---------------------------------------------------------------

commit 857328f4a18658ee7e1fe9af96456274ec415355
Author: ryan <ryan at ratml.org>
Date:   Wed Apr 1 19:11:14 2015 -0400

    Check arma_config.hpp when compiling with mlpack.
    This is for downstream users, not for during the build of mlpack.


>---------------------------------------------------------------

857328f4a18658ee7e1fe9af96456274ec415355
 src/mlpack/core/util/CMakeLists.txt        |  1 +
 src/mlpack/core/util/arma_config_check.hpp | 34 ++++++++++++++++++++++++++++++
 src/mlpack/prereqs.hpp                     |  4 ++++
 3 files changed, 39 insertions(+)

diff --git a/src/mlpack/core/util/CMakeLists.txt b/src/mlpack/core/util/CMakeLists.txt
index 587e936..e410351 100644
--- a/src/mlpack/core/util/CMakeLists.txt
+++ b/src/mlpack/core/util/CMakeLists.txt
@@ -1,6 +1,7 @@
 # Define the files we need to compile.
 # Anything not in this list will not be compiled into MLPACK.
 set(SOURCES
+  arma_config_check.hpp
   cli.hpp
   cli.cpp
   cli_deleter.hpp
diff --git a/src/mlpack/core/util/arma_config_check.hpp b/src/mlpack/core/util/arma_config_check.hpp
new file mode 100644
index 0000000..52ab900
--- /dev/null
+++ b/src/mlpack/core/util/arma_config_check.hpp
@@ -0,0 +1,34 @@
+/**
+ * @file arma_config_check.hpp
+ * @author Ryan Curtin
+ *
+ * Using the contents of arma_config.hpp, try to catch the condition where the
+ * user has included mlpack with ARMA_64BIT_WORD enabled but mlpack was compiled
+ * without ARMA_64BIT_WORD enabled.  This should help prevent a long, drawn-out
+ * debugging process where nobody can figure out why the stack is getting
+ * mangled.
+ */
+#ifndef __MLPACK_CORE_UTIL_ARMA_CONFIG_CHECK_HPP
+#define __MLPACK_CORE_UTIL_ARMA_CONFIG_CHECK_HPP
+
+#include "arma_config.hpp"
+
+#ifdef ARMA_64BIT_WORD
+  #ifdef MLPACK_ARMA_NO_64BIT_WORD
+    #pragma message "mlpack was compiled without ARMA_64BIT_WORD, but you are \
+compiling with ARMA_64BIT_WORD.  This will almost certainly cause irreparable \
+disaster.  Either disable ARMA_64BIT_WORD in your application which is using \
+mlpack, or, recompile mlpack against a version of Armadillo which has \
+ARMA_64BIT_WORD enabled."
+  #endif
+#else
+  #ifdef MLPACK_ARMA_64BIT_WORD
+    #pragma message "mlpack was compiled with ARMA_64BIT_WORD, but you are \
+compiling without ARMA_64BIT_WORD.  This will almost certainly cause \
+irreparable disaster.  Either enable ARMA_64BIT_WORD in your application which \
+is using mlpack, or, recompile mlpack against a version of Armadillo which has \
+ARMA_64BIT_WORD disabled."
+  #endif
+#endif
+
+#endif
diff --git a/src/mlpack/prereqs.hpp b/src/mlpack/prereqs.hpp
index 66c8ec8..21b726f 100644
--- a/src/mlpack/prereqs.hpp
+++ b/src/mlpack/prereqs.hpp
@@ -48,6 +48,10 @@
 // Now include Armadillo through the special mlpack extensions.
 #include <mlpack/core/arma_extend/arma_extend.hpp>
 
+// Ensure that the user isn't doing something stupid with their Armadillo
+// defines.
+#include <mlpack/core/util/arma_config_check.hpp>
+
 // On Visual Studio, disable C4519 (default arguments for function templates)
 // since it's by default an error, which doesn't even make any sense because
 // it's part of the C++11 standard.



More information about the mlpack-git mailing list