diff --git a/HISTORY.md b/HISTORY.md index 46bcf2f9c0..6c5102e1dd 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,6 @@ ### mlpack ?.?.? ###### ????-??-?? + * Fix include ordering issue for `LinearRegression` (#3541). ### mlpack 4.2.1 ###### 2023-09-05 diff --git a/src/mlpack/core/dists/regression_distribution.hpp b/src/mlpack/core/dists/regression_distribution.hpp index 9e9797dc83..252e483d6d 100644 --- a/src/mlpack/core/dists/regression_distribution.hpp +++ b/src/mlpack/core/dists/regression_distribution.hpp @@ -10,8 +10,8 @@ * 3-clause BSD license along with mlpack. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ -#ifndef MLPACK_CORE_DISTRIBUTIONS_REGRESSION_DISTRIBUTION_HPP -#define MLPACK_CORE_DISTRIBUTIONS_REGRESSION_DISTRIBUTION_HPP +#ifndef MLPACK_CORE_DISTS_REGRESSION_DISTRIBUTION_HPP +#define MLPACK_CORE_DISTS_REGRESSION_DISTRIBUTION_HPP #include #include diff --git a/src/mlpack/core/dists/regression_distribution_impl.hpp b/src/mlpack/core/dists/regression_distribution_impl.hpp index a71b1f4eff..328f0c4ab2 100644 --- a/src/mlpack/core/dists/regression_distribution_impl.hpp +++ b/src/mlpack/core/dists/regression_distribution_impl.hpp @@ -10,9 +10,8 @@ * 3-clause BSD license along with mlpack. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ - -#ifndef MLPACK_CORE_DISTRIBUTIONS_REGRESSION_DISTRIBUTION_IMPL_HPP -#define MLPACK_CORE_DISTRIBUTIONS_REGRESSION_DISTRIBUTION_IMPL_HPP +#ifndef MLPACK_CORE_DISTS_REGRESSION_DISTRIBUTION_IMPL_HPP +#define MLPACK_CORE_DISTS_REGRESSION_DISTRIBUTION_IMPL_HPP #include "regression_distribution.hpp" diff --git a/src/mlpack/methods/linear_regression/linear_regression.hpp b/src/mlpack/methods/linear_regression/linear_regression.hpp index 9a0ee221aa..c2d7ce2e2b 100644 --- a/src/mlpack/methods/linear_regression/linear_regression.hpp +++ b/src/mlpack/methods/linear_regression/linear_regression.hpp @@ -13,7 +13,11 @@ #ifndef MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP #define MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP -#include +// Because RegressionDistribution uses LinearRegression internally, we need to +// make sure we define LinearRegression fully before we define +// RegressionDistribution. Therefore we have to include the prereqs first, and +// include the core later. +#include namespace mlpack { @@ -168,4 +172,7 @@ class LinearRegression // Include implementation. #include "linear_regression_impl.hpp" +// Now that LinearRegression is defined, we can include the core. +#include + #endif // MLPACK_METHODS_LINEAR_REGRESSION_HPP