[mlpack-git] master: Add a bit of documentation for what MLPACK_EXPORT is and why it is there. (7264d37)

gitdub at mlpack.org gitdub at mlpack.org
Mon Apr 25 14:32:07 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/aa7e51352127e809c9be9c1ec5cd94cb35f2fbd3...7264d37128a9f97ee1f0d481f37cc2bf1d3b1f30

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

commit 7264d37128a9f97ee1f0d481f37cc2bf1d3b1f30
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Apr 25 14:32:07 2016 -0400

    Add a bit of documentation for what MLPACK_EXPORT is and why it is there.


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

7264d37128a9f97ee1f0d481f37cc2bf1d3b1f30
 src/mlpack/CMakeLists.txt       | 3 +++
 src/mlpack/core/math/random.hpp | 8 ++++++--
 src/mlpack/core/util/log.hpp    | 5 ++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/mlpack/CMakeLists.txt b/src/mlpack/CMakeLists.txt
index 8a7fc73..51bea6c 100644
--- a/src/mlpack/CMakeLists.txt
+++ b/src/mlpack/CMakeLists.txt
@@ -22,6 +22,9 @@ endif ()
 # MLPACK_SRCS is set in the subdirectories.
 add_library(mlpack ${MLPACK_SRCS})
 
+# Generate export symbols for Windows, instead of adding __declspec(dllimport)
+# and __declspec(dllexport) everywhere.  However, those modifiers are still
+# necessary for global variables (of which there are a few in mlpack).
 set_target_properties(mlpack PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
 include(GenerateExportHeader)
 generate_export_header(mlpack)
diff --git a/src/mlpack/core/math/random.hpp b/src/mlpack/core/math/random.hpp
index 03c274f..c613069 100644
--- a/src/mlpack/core/math/random.hpp
+++ b/src/mlpack/core/math/random.hpp
@@ -6,14 +6,18 @@
 #ifndef MLPACK_CORE_MATH_RANDOM_HPP
 #define MLPACK_CORE_MATH_RANDOM_HPP
 
-#include <mlpack_export.h>
-
 #include <mlpack/prereqs.hpp>
+#include <mlpack_export.h>
 #include <random>
 
 namespace mlpack {
 namespace math /** Miscellaneous math routines. */ {
 
+/**
+ * MLPACK_EXPORT is required for global variables; it exports the symbols
+ * correctly on Windows.
+ */
+
 // Global random object.
 extern MLPACK_EXPORT std::mt19937 randGen;
 // Global uniform distribution.
diff --git a/src/mlpack/core/util/log.hpp b/src/mlpack/core/util/log.hpp
index 1db69ed..c0c56ab 100644
--- a/src/mlpack/core/util/log.hpp
+++ b/src/mlpack/core/util/log.hpp
@@ -8,7 +8,6 @@
 #define MLPACK_CORE_UTIL_LOG_HPP
 
 #include <string>
-
 #include <mlpack_export.h>
 
 #include "prefixedoutstream.hpp"
@@ -60,6 +59,10 @@ class Log
   static void Assert(bool condition,
                      const std::string& message = "Assert Failed.");
 
+  /**
+   * MLPACK_EXPORT is required for global variables, so that they are properly
+   * exported by the Windows compiler.
+   */
 
   // We only use PrefixedOutStream if the program is compiled with debug
   // symbols.




More information about the mlpack-git mailing list