From 594facdb031d305c41e715f45f67a1814448fde3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 13 Dec 2023 16:50:28 +0100
Subject: [PATCH] MEX files: homogeneize include guards

Also ensure that guards are not reserved identifiers (i.e. starting with an
underscore).
---
 mex/sources/bytecode/BasicSymbolTable.hh      |  6 ++---
 mex/sources/bytecode/ErrorHandling.hh         |  8 +++----
 mex/sources/bytecode/Evaluate.hh              |  6 ++---
 mex/sources/bytecode/Interpreter.hh           |  6 ++---
 mex/sources/bytecode/Mem_Mngr.hh              |  8 +++----
 mex/sources/dynblas.h                         |  6 ++---
 mex/sources/dynlapack.h                       |  6 ++---
 mex/sources/dynmex.h                          |  4 ++--
 mex/sources/dynumfpack.h                      |  6 ++---
 .../k_order_welfare/approximation_welfare.hh  |  4 ++--
 .../k_order_welfare/k_ord_objective.hh        |  4 ++--
 .../objective_abstract_class.hh               |  6 ++---
 mex/sources/k_order_welfare/objective_m.hh    |  4 ++--
 .../libkorder/dynamic_abstract_class.hh       |  6 ++---
 mex/sources/libkorder/dynamic_dll.hh          |  4 ++--
 mex/sources/libkorder/dynamic_m.hh            |  4 ++--
 mex/sources/libkorder/k_ord_dynare.hh         |  4 ++--
 mex/sources/libkorder/kord/approximation.hh   |  4 ++--
 mex/sources/libkorder/kord/decision_rule.hh   |  4 ++--
 mex/sources/libkorder/kord/dynamic_model.hh   |  4 ++--
 mex/sources/libkorder/kord/faa_di_bruno.hh    |  6 ++---
 mex/sources/libkorder/kord/first_order.hh     |  4 ++--
 mex/sources/libkorder/kord/journal.hh         |  6 ++---
 mex/sources/libkorder/kord/kord_exception.hh  | 22 +++++++++----------
 mex/sources/libkorder/kord/korder.hh          |  4 ++--
 mex/sources/libkorder/kord/korder_stoch.hh    |  5 +++++
 mex/sources/libkorder/sylv/BlockDiagonal.hh   |  6 ++---
 mex/sources/libkorder/sylv/GeneralMatrix.hh   |  6 ++---
 .../libkorder/sylv/GeneralSylvester.hh        |  6 ++---
 .../libkorder/sylv/IterativeSylvester.hh      |  8 +++----
 mex/sources/libkorder/sylv/KronUtils.hh       |  8 +++----
 mex/sources/libkorder/sylv/KronVector.hh      |  6 ++---
 mex/sources/libkorder/sylv/QuasiTriangular.hh |  6 ++---
 .../libkorder/sylv/QuasiTriangularZero.hh     |  6 ++---
 mex/sources/libkorder/sylv/SchurDecomp.hh     |  6 ++---
 mex/sources/libkorder/sylv/SchurDecompEig.hh  |  8 +++----
 .../libkorder/sylv/SimilarityDecomp.hh        |  6 ++---
 mex/sources/libkorder/sylv/SylvException.hh   |  6 ++---
 mex/sources/libkorder/sylv/SylvMatrix.hh      |  8 +++----
 mex/sources/libkorder/sylv/SylvParams.hh      |  6 ++---
 mex/sources/libkorder/sylv/SylvesterSolver.hh |  8 +++----
 mex/sources/libkorder/sylv/SymSchurDecomp.hh  |  4 ++--
 .../libkorder/sylv/TriangularSylvester.hh     |  6 ++---
 mex/sources/libkorder/sylv/Vector.hh          |  6 ++---
 mex/sources/libkorder/sylv/tests/MMMatrix.hh  |  6 ++---
 mex/sources/libkorder/tl/equivalence.hh       |  4 ++--
 mex/sources/libkorder/tl/fine_container.hh    |  4 ++--
 mex/sources/libkorder/tl/fs_tensor.hh         |  4 ++--
 mex/sources/libkorder/tl/gs_tensor.hh         |  4 ++--
 mex/sources/libkorder/tl/int_sequence.hh      |  4 ++--
 mex/sources/libkorder/tl/kron_prod.hh         |  4 ++--
 mex/sources/libkorder/tl/normal_moments.hh    |  4 ++--
 mex/sources/libkorder/tl/permutation.hh       |  4 ++--
 mex/sources/libkorder/tl/ps_tensor.hh         |  4 ++--
 mex/sources/libkorder/tl/pyramid_prod.hh      |  4 ++--
 mex/sources/libkorder/tl/pyramid_prod2.hh     |  4 ++--
 mex/sources/libkorder/tl/rfs_tensor.hh        |  4 ++--
 mex/sources/libkorder/tl/sparse_tensor.hh     |  4 ++--
 mex/sources/libkorder/tl/stack_container.hh   |  4 ++--
 mex/sources/libkorder/tl/symmetry.hh          |  4 ++--
 mex/sources/libkorder/tl/t_container.hh       |  4 ++--
 mex/sources/libkorder/tl/t_polynomial.hh      |  5 +++++
 mex/sources/libkorder/tl/tensor.hh            |  4 ++--
 mex/sources/libkorder/tl/tests/factory.hh     |  4 ++--
 mex/sources/libkorder/tl/tests/monoms.hh      |  4 ++--
 mex/sources/libkorder/tl/tl_exception.hh      |  4 ++--
 mex/sources/libkorder/tl/tl_static.hh         |  4 ++--
 mex/sources/libkorder/tl/twod_matrix.hh       |  4 ++--
 .../libkorder/utils/dynare_exception.hh       |  4 ++--
 mex/sources/libkorder/utils/exception.hh      |  4 ++--
 mex/sources/libkorder/utils/int_power.hh      |  7 +++++-
 .../libkorder/utils/pascal_triangle.hh        |  6 ++---
 mex/sources/libkorder/utils/sthread.hh        |  6 ++---
 mex/sources/ms-sbvar/modify_for_mex.h         |  6 ++---
 .../DynamicModelCaller.hh                     |  5 +++++
 mex/sources/sobol/gaussian.hh                 |  5 +++++
 mex/sources/sobol/sobol.hh                    |  5 +++++
 77 files changed, 222 insertions(+), 192 deletions(-)

diff --git a/mex/sources/bytecode/BasicSymbolTable.hh b/mex/sources/bytecode/BasicSymbolTable.hh
index 31a39ead4..e578b3fd7 100644
--- a/mex/sources/bytecode/BasicSymbolTable.hh
+++ b/mex/sources/bytecode/BasicSymbolTable.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _BASIC_SYMBOL_TABLE_HH
-#define _BASIC_SYMBOL_TABLE_HH
+#ifndef BASIC_SYMBOL_TABLE_HH
+#define BASIC_SYMBOL_TABLE_HH
 
 #include <map>
 #include <string>
@@ -44,4 +44,4 @@ private:
   map<string, pair<SymbolType, int>> name_to_id_and_type;
 };
 
-#endif // _BASIC_SYMBOL_TABLE_HH
+#endif
diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh
index 49ec933eb..066c4f79c 100644
--- a/mex/sources/bytecode/ErrorHandling.hh
+++ b/mex/sources/bytecode/ErrorHandling.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007-2022 Dynare Team
+ * Copyright © 2007-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _ERROR_HANDLING_HH
-#define _ERROR_HANDLING_HH
+#ifndef ERROR_HANDLING_HH
+#define ERROR_HANDLING_HH
 
 #include <cmath>
 #include <sstream>
@@ -111,4 +111,4 @@ test_mxMalloc(void* z, int line, const string& file, const string& func, int amo
 extern "C" bool utIsInterruptPending();
 #endif
 
-#endif // _ERROR_HANDLING_HH
+#endif
diff --git a/mex/sources/bytecode/Evaluate.hh b/mex/sources/bytecode/Evaluate.hh
index bb5d2a008..0903dfd13 100644
--- a/mex/sources/bytecode/Evaluate.hh
+++ b/mex/sources/bytecode/Evaluate.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _EVALUATE_HH
-#define _EVALUATE_HH
+#ifndef EVALUATE_HH
+#define EVALUATE_HH
 
 #include <deque>
 #include <filesystem>
@@ -170,4 +170,4 @@ public:
   }
 };
 
-#endif // _EVALUATE_HH
+#endif
diff --git a/mex/sources/bytecode/Interpreter.hh b/mex/sources/bytecode/Interpreter.hh
index 1a59c7535..857b8584c 100644
--- a/mex/sources/bytecode/Interpreter.hh
+++ b/mex/sources/bytecode/Interpreter.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _INTERPRETER_HH
-#define _INTERPRETER_HH
+#ifndef INTERPRETER_HH
+#define INTERPRETER_HH
 
 #include <cstddef>
 #include <fstream>
@@ -287,4 +287,4 @@ public:
   }
 };
 
-#endif // _INTERPRETER_HH
+#endif
diff --git a/mex/sources/bytecode/Mem_Mngr.hh b/mex/sources/bytecode/Mem_Mngr.hh
index 9ba250ca1..7b0d0de65 100644
--- a/mex/sources/bytecode/Mem_Mngr.hh
+++ b/mex/sources/bytecode/Mem_Mngr.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007-2021 Dynare Team
+ * Copyright © 2007-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _MEM_MNGR_HH
-#define _MEM_MNGR_HH
+#ifndef MEM_MNGR_HH
+#define MEM_MNGR_HH
 
 #include <fstream>
 #include <string>
@@ -61,4 +61,4 @@ private:
   string filename_mem;
 };
 
-#endif // _MEM_MNGR_HH
+#endif
diff --git a/mex/sources/dynblas.h b/mex/sources/dynblas.h
index 6956fd30e..5c5c1aaa9 100644
--- a/mex/sources/dynblas.h
+++ b/mex/sources/dynblas.h
@@ -26,8 +26,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNBLAS_H
-#define _DYNBLAS_H
+#ifndef DYNBLAS_H
+#define DYNBLAS_H
 
 #if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
@@ -134,4 +134,4 @@ extern "C"
 } /* extern "C" */
 #endif
 
-#endif /* _DYNBLAS_H */
+#endif
diff --git a/mex/sources/dynlapack.h b/mex/sources/dynlapack.h
index d17ed955a..f9174381b 100644
--- a/mex/sources/dynlapack.h
+++ b/mex/sources/dynlapack.h
@@ -26,8 +26,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNLAPACK_H
-#define _DYNLAPACK_H
+#ifndef DYNLAPACK_H
+#define DYNLAPACK_H
 
 #if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
@@ -231,4 +231,4 @@ extern "C"
 } /* extern "C" */
 #endif
 
-#endif /* _DYNLAPACK_H */
+#endif
diff --git a/mex/sources/dynmex.h b/mex/sources/dynmex.h
index c7a839598..f555615e7 100644
--- a/mex/sources/dynmex.h
+++ b/mex/sources/dynmex.h
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNMEX_H
-#define _DYNMEX_H
+#ifndef DYNMEX_H
+#define DYNMEX_H
 
 #if !defined(MATLAB_MEX_FILE) && !defined(OCTAVE_MEX_FILE)
 # error You must define either MATLAB_MEX_FILE or OCTAVE_MEX_FILE
diff --git a/mex/sources/dynumfpack.h b/mex/sources/dynumfpack.h
index 6597c2f2f..ae3e11c94 100644
--- a/mex/sources/dynumfpack.h
+++ b/mex/sources/dynumfpack.h
@@ -21,8 +21,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNUMFPACK_H
-#define _DYNUMFPACK_H
+#ifndef DYNUMFPACK_H
+#define DYNUMFPACK_H
 
 #ifdef OCTAVE_MEX_FILE
 # ifdef HAVE_SUITESPARSE_UMFPACK_H
@@ -108,4 +108,4 @@ typedef long SuiteSparse_long;
 # endif
 
 #endif // OCTAVE_MEX_FILE
-#endif /* DYNUMFPACK */
+#endif
diff --git a/mex/sources/k_order_welfare/approximation_welfare.hh b/mex/sources/k_order_welfare/approximation_welfare.hh
index 5fd4fcb68..1badac67c 100644
--- a/mex/sources/k_order_welfare/approximation_welfare.hh
+++ b/mex/sources/k_order_welfare/approximation_welfare.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef APPROXIMATION_WELFARE_H
-#define APPROXIMATION_WELFARE_H
+#ifndef APPROXIMATION_WELFARE_HH
+#define APPROXIMATION_WELFARE_HH
 
 #include "journal.hh"
 #include "k_ord_objective.hh"
diff --git a/mex/sources/k_order_welfare/k_ord_objective.hh b/mex/sources/k_order_welfare/k_ord_objective.hh
index 288f39b69..71b0a38f5 100644
--- a/mex/sources/k_order_welfare/k_ord_objective.hh
+++ b/mex/sources/k_order_welfare/k_ord_objective.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef K_ORD_OBJECTIVE_H
-#define K_ORD_OBJECTIVE_H
+#ifndef K_ORD_OBJECTIVE_HH
+#define K_ORD_OBJECTIVE_HH
 
 #include "k_ord_dynare.hh"
 #include "objective_abstract_class.hh"
diff --git a/mex/sources/k_order_welfare/objective_abstract_class.hh b/mex/sources/k_order_welfare/objective_abstract_class.hh
index 83a3ac98a..6dd7a3dfe 100644
--- a/mex/sources/k_order_welfare/objective_abstract_class.hh
+++ b/mex/sources/k_order_welfare/objective_abstract_class.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2021 Dynare Team
+ * Copyright © 2021-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _OBJECTIVEAC_HH
-#define _OBJECTIVEAC_HH
+#ifndef OBJECTIVE_ABSTRACT_CLASS_HH
+#define OBJECTIVE_ABSTRACT_CLASS_HH
 
 #include <vector>
 
diff --git a/mex/sources/k_order_welfare/objective_m.hh b/mex/sources/k_order_welfare/objective_m.hh
index fec3ce89a..4de2aec51 100644
--- a/mex/sources/k_order_welfare/objective_m.hh
+++ b/mex/sources/k_order_welfare/objective_m.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _OBJECTIVE_M_HH
-#define _OBJECTIVE_M_HH
+#ifndef OBJECTIVE_M_HH
+#define OBJECTIVE_M_HH
 
 #include "objective_abstract_class.hh"
 
diff --git a/mex/sources/libkorder/dynamic_abstract_class.hh b/mex/sources/libkorder/dynamic_abstract_class.hh
index b4928010d..951e845bf 100644
--- a/mex/sources/libkorder/dynamic_abstract_class.hh
+++ b/mex/sources/libkorder/dynamic_abstract_class.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2019 Dynare Team
+ * Copyright © 2010-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNAMICMODELAC_HH
-#define _DYNAMICMODELAC_HH
+#ifndef DYNAMIC_ABSTRACT_CLASS_HH
+#define DYNAMIC_ABSTRACT_CLASS_HH
 
 #include <vector>
 
diff --git a/mex/sources/libkorder/dynamic_dll.hh b/mex/sources/libkorder/dynamic_dll.hh
index 7b8af3f68..8eca28d9c 100644
--- a/mex/sources/libkorder/dynamic_dll.hh
+++ b/mex/sources/libkorder/dynamic_dll.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNAMIC_DLL_HH
-#define _DYNAMIC_DLL_HH
+#ifndef DYNAMIC_DLL_HH
+#define DYNAMIC_DLL_HH
 
 #if defined(_WIN32) || defined(__CYGWIN32__)
 # ifndef NOMINMAX
diff --git a/mex/sources/libkorder/dynamic_m.hh b/mex/sources/libkorder/dynamic_m.hh
index 697686f0a..bf89e9847 100644
--- a/mex/sources/libkorder/dynamic_m.hh
+++ b/mex/sources/libkorder/dynamic_m.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _DYNAMIC_M_HH
-#define _DYNAMIC_M_HH
+#ifndef DYNAMIC_M_HH
+#define DYNAMIC_M_HH
 
 #include "dynamic_abstract_class.hh"
 
diff --git a/mex/sources/libkorder/k_ord_dynare.hh b/mex/sources/libkorder/k_ord_dynare.hh
index 0e7a53d42..6d45ce82c 100644
--- a/mex/sources/libkorder/k_ord_dynare.hh
+++ b/mex/sources/libkorder/k_ord_dynare.hh
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef K_ORD_DYNARE3_H
-#define K_ORD_DYNARE3_H
+#ifndef K_ORD_DYNARE_HH
+#define K_ORD_DYNARE_HH
 
 #include <memory>
 #include <string>
diff --git a/mex/sources/libkorder/kord/approximation.hh b/mex/sources/libkorder/kord/approximation.hh
index 4ffff1f10..48d58e035 100644
--- a/mex/sources/libkorder/kord/approximation.hh
+++ b/mex/sources/libkorder/kord/approximation.hh
@@ -61,8 +61,8 @@
    calculate also its unfolded versions, to be available for simulations
    and so on. */
 
-#ifndef APPROXIMATION_H
-#define APPROXIMATION_H
+#ifndef APPROXIMATION_HH
+#define APPROXIMATION_HH
 
 #include "decision_rule.hh"
 #include "dynamic_model.hh"
diff --git a/mex/sources/libkorder/kord/decision_rule.hh b/mex/sources/libkorder/kord/decision_rule.hh
index 4e712ea0d..877fd5e59 100644
--- a/mex/sources/libkorder/kord/decision_rule.hh
+++ b/mex/sources/libkorder/kord/decision_rule.hh
@@ -32,8 +32,8 @@
    DRFixPoint allows for calculation of the fix point of a given decision
    rule. */
 
-#ifndef DECISION_RULE_H
-#define DECISION_RULE_H
+#ifndef DECISION_RULE_HH
+#define DECISION_RULE_HH
 
 #include "kord_exception.hh"
 #include "korder.hh"
diff --git a/mex/sources/libkorder/kord/dynamic_model.hh b/mex/sources/libkorder/kord/dynamic_model.hh
index da1103468..09b0d9632 100644
--- a/mex/sources/libkorder/kord/dynamic_model.hh
+++ b/mex/sources/libkorder/kord/dynamic_model.hh
@@ -27,8 +27,8 @@
 
    The interface is defined via pure virtual class DynamicModel. */
 
-#ifndef DYNAMIC_MODEL_H
-#define DYNAMIC_MODEL_H
+#ifndef DYNAMIC_MODEL_HH
+#define DYNAMIC_MODEL_HH
 
 #include "sparse_tensor.hh"
 #include "t_container.hh"
diff --git a/mex/sources/libkorder/kord/faa_di_bruno.hh b/mex/sources/libkorder/kord/faa_di_bruno.hh
index 1e3902b8a..c9b320a53 100644
--- a/mex/sources/libkorder/kord/faa_di_bruno.hh
+++ b/mex/sources/libkorder/kord/faa_di_bruno.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2005 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -29,8 +29,8 @@
    where sᵏ is a general symmetry of dimension k and z is a stack of
    functions. */
 
-#ifndef FAA_DI_BRUNO_H
-#define FAA_DI_BRUNO_H
+#ifndef FAA_DI_BRUNO_HH
+#define FAA_DI_BRUNO_HH
 
 #include "gs_tensor.hh"
 #include "journal.hh"
diff --git a/mex/sources/libkorder/kord/first_order.hh b/mex/sources/libkorder/kord/first_order.hh
index fde9009b5..5b6e9d1e4 100644
--- a/mex/sources/libkorder/kord/first_order.hh
+++ b/mex/sources/libkorder/kord/first_order.hh
@@ -20,8 +20,8 @@
 
 // First order at deterministic steady state
 
-#ifndef FIRST_ORDER_H
-#define FIRST_ORDER_H
+#ifndef FIRST_ORDER_HH
+#define FIRST_ORDER_HH
 
 #include "korder.hh"
 
diff --git a/mex/sources/libkorder/kord/journal.hh b/mex/sources/libkorder/kord/journal.hh
index 5e18a5414..965dd25ff 100644
--- a/mex/sources/libkorder/kord/journal.hh
+++ b/mex/sources/libkorder/kord/journal.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 Ondra Kamenik
- * Copyright © 2019-2020 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -20,8 +20,8 @@
 
 // Resource usage journal
 
-#ifndef JOURNAL_H
-#define JOURNAL_H
+#ifndef JOURNAL_HH
+#define JOURNAL_HH
 
 #include "int_sequence.hh"
 
diff --git a/mex/sources/libkorder/kord/kord_exception.hh b/mex/sources/libkorder/kord/kord_exception.hh
index 343756e9c..83508ab92 100644
--- a/mex/sources/libkorder/kord/kord_exception.hh
+++ b/mex/sources/libkorder/kord/kord_exception.hh
@@ -22,23 +22,23 @@
 
 /* This is a simple code defining an exception and two convenience macros. */
 
+#ifndef KORD_EXCEPTION_HH
+#define KORD_EXCEPTION_HH
+
 #include <iostream>
 #include <string>
 
-#ifndef KORD_EXCEPTION_H
-# define KORD_EXCEPTION_H
-
-# define KORD_RAISE(mes) throw KordException(__FILE__, __LINE__, mes);
+#define KORD_RAISE(mes) throw KordException(__FILE__, __LINE__, mes);
 
-# define KORD_RAISE_IF(expr, mes)                                                                  \
-  if (expr)                                                                                        \
-   throw KordException(__FILE__, __LINE__, mes);
+#define KORD_RAISE_IF(expr, mes)                                                                   \
+ if (expr)                                                                                         \
+  throw KordException(__FILE__, __LINE__, mes);
 
-# define KORD_RAISE_X(mes, c) throw KordException(__FILE__, __LINE__, mes, c);
+#define KORD_RAISE_X(mes, c) throw KordException(__FILE__, __LINE__, mes, c);
 
-# define KORD_RAISE_IF_X(expr, mes, c)                                                             \
-  if (expr)                                                                                        \
-   throw KordException(__FILE__, __LINE__, mes, c);
+#define KORD_RAISE_IF_X(expr, mes, c)                                                              \
+ if (expr)                                                                                         \
+  throw KordException(__FILE__, __LINE__, mes, c);
 
 class KordException
 {
diff --git a/mex/sources/libkorder/kord/korder.hh b/mex/sources/libkorder/kord/korder.hh
index d4d8b3c5a..5d6fd8c1a 100644
--- a/mex/sources/libkorder/kord/korder.hh
+++ b/mex/sources/libkorder/kord/korder.hh
@@ -38,8 +38,8 @@
    PartitionY, MatrixA, MatrixS and MatrixB.
 */
 
-#ifndef KORDER_H
-#define KORDER_H
+#ifndef KORDER_HH
+#define KORDER_HH
 
 #include "faa_di_bruno.hh"
 #include "fs_tensor.hh"
diff --git a/mex/sources/libkorder/kord/korder_stoch.hh b/mex/sources/libkorder/kord/korder_stoch.hh
index 011f3f015..48f324043 100644
--- a/mex/sources/libkorder/kord/korder_stoch.hh
+++ b/mex/sources/libkorder/kord/korder_stoch.hh
@@ -38,6 +38,9 @@
    h as an extrapolation based on an approximation to g at lower σ.
 */
 
+#ifndef KORDER_STOCH_HH
+#define KORDER_STOCH_HH
+
 #include <memory>
 
 #include "faa_di_bruno.hh"
@@ -573,3 +576,5 @@ KOrderStoch::performStep(int order)
         Gstack<t>().multAndAdd(1, h<t>(), *G_sym_ptr);
       }
 }
+
+#endif
diff --git a/mex/sources/libkorder/sylv/BlockDiagonal.hh b/mex/sources/libkorder/sylv/BlockDiagonal.hh
index 41e9522c3..12dedecb6 100644
--- a/mex/sources/libkorder/sylv/BlockDiagonal.hh
+++ b/mex/sources/libkorder/sylv/BlockDiagonal.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef BLOCK_DIAGONAL_H
-#define BLOCK_DIAGONAL_H
+#ifndef BLOCK_DIAGONAL_HH
+#define BLOCK_DIAGONAL_HH
 
 #include <memory>
 #include <vector>
@@ -70,4 +70,4 @@ private:
                           Vector& work) const;
 };
 
-#endif /* BLOCK_DIAGONAL_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/GeneralMatrix.hh b/mex/sources/libkorder/sylv/GeneralMatrix.hh
index 097181b1a..aec8c139e 100644
--- a/mex/sources/libkorder/sylv/GeneralMatrix.hh
+++ b/mex/sources/libkorder/sylv/GeneralMatrix.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef GENERAL_MATRIX_H
-#define GENERAL_MATRIX_H
+#ifndef GENERAL_MATRIX_HH
+#define GENERAL_MATRIX_HH
 
 #include "SylvException.hh"
 #include "Vector.hh"
@@ -611,4 +611,4 @@ private:
   void construct(const GeneralMatrix& A);
 };
 
-#endif /* GENERAL_MATRIX_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/GeneralSylvester.hh b/mex/sources/libkorder/sylv/GeneralSylvester.hh
index 76d626a2e..910311ab2 100644
--- a/mex/sources/libkorder/sylv/GeneralSylvester.hh
+++ b/mex/sources/libkorder/sylv/GeneralSylvester.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef GENERAL_SYLVESTER_H
-#define GENERAL_SYLVESTER_H
+#ifndef GENERAL_SYLVESTER_HH
+#define GENERAL_SYLVESTER_HH
 
 #include "SimilarityDecomp.hh"
 #include "SylvMatrix.hh"
@@ -87,4 +87,4 @@ private:
   void init();
 };
 
-#endif /* GENERAL_SYLVESTER_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/IterativeSylvester.hh b/mex/sources/libkorder/sylv/IterativeSylvester.hh
index 85ad47a0d..acc58a247 100644
--- a/mex/sources/libkorder/sylv/IterativeSylvester.hh
+++ b/mex/sources/libkorder/sylv/IterativeSylvester.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004-2011 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef ITERATIVE_SYLVESTER_H
-#define ITERATIVE_SYLVESTER_H
+#ifndef ITERATIVE_SYLVESTER_HH
+#define ITERATIVE_SYLVESTER_HH
 
 #include "KronVector.hh"
 #include "QuasiTriangular.hh"
@@ -47,4 +47,4 @@ private:
   static double performStep(const QuasiTriangular& k, const QuasiTriangular& f, KronVector& x);
 };
 
-#endif /* ITERATIVE_SYLVESTER_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/KronUtils.hh b/mex/sources/libkorder/sylv/KronUtils.hh
index cfa1d1bc9..3125c88bc 100644
--- a/mex/sources/libkorder/sylv/KronUtils.hh
+++ b/mex/sources/libkorder/sylv/KronUtils.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004-2011 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef KRON_UTILS_H
-#define KRON_UTILS_H
+#ifndef KRON_UTILS_HH
+#define KRON_UTILS_HH
 
 #include "KronVector.hh"
 #include "QuasiTriangular.hh"
@@ -38,4 +38,4 @@ public:
   static void multKron(const QuasiTriangular& f, const QuasiTriangular& k, KronVector& x);
 };
 
-#endif /* KRON_UTILS_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/KronVector.hh b/mex/sources/libkorder/sylv/KronVector.hh
index 054053994..6cb0bb1dd 100644
--- a/mex/sources/libkorder/sylv/KronVector.hh
+++ b/mex/sources/libkorder/sylv/KronVector.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef KRON_VECTOR_H
-#define KRON_VECTOR_H
+#ifndef KRON_VECTOR_HH
+#define KRON_VECTOR_HH
 
 #include "Vector.hh"
 
@@ -101,4 +101,4 @@ public:
   }
 };
 
-#endif /* KRON_VECTOR */
+#endif
diff --git a/mex/sources/libkorder/sylv/QuasiTriangular.hh b/mex/sources/libkorder/sylv/QuasiTriangular.hh
index 6b46a4d7c..a719a0408 100644
--- a/mex/sources/libkorder/sylv/QuasiTriangular.hh
+++ b/mex/sources/libkorder/sylv/QuasiTriangular.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef QUASI_TRIANGULAR_H
-#define QUASI_TRIANGULAR_H
+#ifndef QUASI_TRIANGULAR_HH
+#define QUASI_TRIANGULAR_HH
 
 #include "KronVector.hh"
 #include "SylvMatrix.hh"
@@ -472,4 +472,4 @@ private:
   void multsVecTrans(Vector& x, const ConstVector& d) const;
 };
 
-#endif /* QUASI_TRIANGULAR_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/QuasiTriangularZero.hh b/mex/sources/libkorder/sylv/QuasiTriangularZero.hh
index bea53024f..acc0b1eea 100644
--- a/mex/sources/libkorder/sylv/QuasiTriangularZero.hh
+++ b/mex/sources/libkorder/sylv/QuasiTriangularZero.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef QUASI_TRIANGULAR_ZERO_H
-#define QUASI_TRIANGULAR_ZERO_H
+#ifndef QUASI_TRIANGULAR_ZERO_HH
+#define QUASI_TRIANGULAR_ZERO_HH
 
 #include "GeneralMatrix.hh"
 #include "QuasiTriangular.hh"
@@ -84,4 +84,4 @@ public:
   void print() const override;
 };
 
-#endif /* QUASI_TRIANGULAR_ZERO_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SchurDecomp.hh b/mex/sources/libkorder/sylv/SchurDecomp.hh
index ee3ffc608..0c5b9d967 100644
--- a/mex/sources/libkorder/sylv/SchurDecomp.hh
+++ b/mex/sources/libkorder/sylv/SchurDecomp.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SCHUR_DECOMP_H
-#define SCHUR_DECOMP_H
+#ifndef SCHUR_DECOMP_HH
+#define SCHUR_DECOMP_HH
 
 #include "QuasiTriangular.hh"
 #include "SylvMatrix.hh"
@@ -80,4 +80,4 @@ public:
   }
 };
 
-#endif /* SCHUR_DECOMP_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SchurDecompEig.hh b/mex/sources/libkorder/sylv/SchurDecompEig.hh
index 63967d769..c5a74c47b 100644
--- a/mex/sources/libkorder/sylv/SchurDecompEig.hh
+++ b/mex/sources/libkorder/sylv/SchurDecompEig.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004-2011 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -20,8 +20,8 @@
 
 // contains algorithms for eigenvalue reordering
 
-#ifndef SCHUR_DECOMP_EIG_H
-#define SCHUR_DECOMP_EIG_H
+#ifndef SCHUR_DECOMP_EIG_HH
+#define SCHUR_DECOMP_EIG_HH
 
 #include "QuasiTriangular.hh"
 #include "SchurDecomp.hh"
@@ -44,4 +44,4 @@ protected:
   bool tryToSwap(diag_iter& it, diag_iter& itadd);
 };
 
-#endif /* SCHUR_DECOMP_EIG_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SimilarityDecomp.hh b/mex/sources/libkorder/sylv/SimilarityDecomp.hh
index 77e8bdf0b..dabbd395d 100644
--- a/mex/sources/libkorder/sylv/SimilarityDecomp.hh
+++ b/mex/sources/libkorder/sylv/SimilarityDecomp.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SIMILARITY_DECOMP_H
-#define SIMILARITY_DECOMP_H
+#ifndef SIMILARITY_DECOMP_HH
+#define SIMILARITY_DECOMP_HH
 
 #include "BlockDiagonal.hh"
 #include "SylvMatrix.hh"
@@ -63,4 +63,4 @@ protected:
   void diagonalize(double norm);
 };
 
-#endif /* SIMILARITY_DECOMP_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SylvException.hh b/mex/sources/libkorder/sylv/SylvException.hh
index c7fd0c422..b18bf53e5 100644
--- a/mex/sources/libkorder/sylv/SylvException.hh
+++ b/mex/sources/libkorder/sylv/SylvException.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SYLV_EXCEPTION_H
-#define SYLV_EXCEPTION_H
+#ifndef SYLV_EXCEPTION_HH
+#define SYLV_EXCEPTION_HH
 
 #include <string>
 
@@ -48,4 +48,4 @@ public:
 // define macros:
 #define SYLV_MES_EXCEPTION(mes) (SylvExceptionMessage(__FILE__, __LINE__, mes))
 
-#endif /* SYLV_EXCEPTION_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SylvMatrix.hh b/mex/sources/libkorder/sylv/SylvMatrix.hh
index c5ae4185b..eaaa0500b 100644
--- a/mex/sources/libkorder/sylv/SylvMatrix.hh
+++ b/mex/sources/libkorder/sylv/SylvMatrix.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004-2011 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SYLV_MATRIX_H
-#define SYLV_MATRIX_H
+#ifndef SYLV_MATRIX_HH
+#define SYLV_MATRIX_HH
 
 #include "GeneralMatrix.hh"
 #include "KronVector.hh"
@@ -105,4 +105,4 @@ public:
   void setUnit();
 };
 
-#endif /* SYLV_MATRIX_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SylvParams.hh b/mex/sources/libkorder/sylv/SylvParams.hh
index 0f4204bf7..21e6a800c 100644
--- a/mex/sources/libkorder/sylv/SylvParams.hh
+++ b/mex/sources/libkorder/sylv/SylvParams.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SYLV_PARAMS_H
-#define SYLV_PARAMS_H
+#ifndef SYLV_PARAMS_HH
+#define SYLV_PARAMS_HH
 
 #include <ostream>
 #include <string>
@@ -235,4 +235,4 @@ operator<<(std::ostream& out, SylvParams::solve_method m)
   return out;
 }
 
-#endif /* SYLV_PARAMS_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SylvesterSolver.hh b/mex/sources/libkorder/sylv/SylvesterSolver.hh
index 9543ffce6..d5de5cb23 100644
--- a/mex/sources/libkorder/sylv/SylvesterSolver.hh
+++ b/mex/sources/libkorder/sylv/SylvesterSolver.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004-2011 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SYLVESTER_SOLVER_H
-#define SYLVESTER_SOLVER_H
+#ifndef SYLVESTER_SOLVER_HH
+#define SYLVESTER_SOLVER_HH
 
 #include "KronVector.hh"
 #include "QuasiTriangular.hh"
@@ -66,4 +66,4 @@ public:
   virtual void solve(SylvParams& pars, KronVector& x) const = 0;
 };
 
-#endif /* SYLVESTER_SOLVER_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/SymSchurDecomp.hh b/mex/sources/libkorder/sylv/SymSchurDecomp.hh
index 6460155c6..ac558792e 100644
--- a/mex/sources/libkorder/sylv/SymSchurDecomp.hh
+++ b/mex/sources/libkorder/sylv/SymSchurDecomp.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef SYM_SCHUR_DECOMP_H
-#define SYM_SCHUR_DECOMP_H
+#ifndef SYM_SCHUR_DECOMP_HH
+#define SYM_SCHUR_DECOMP_HH
 
 #include "SylvMatrix.hh"
 
diff --git a/mex/sources/libkorder/sylv/TriangularSylvester.hh b/mex/sources/libkorder/sylv/TriangularSylvester.hh
index 60d6b0187..d5949b05a 100644
--- a/mex/sources/libkorder/sylv/TriangularSylvester.hh
+++ b/mex/sources/libkorder/sylv/TriangularSylvester.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef TRIANGULAR_SYLVESTER_H
-#define TRIANGULAR_SYLVESTER_H
+#ifndef TRIANGULAR_SYLVESTER_HH
+#define TRIANGULAR_SYLVESTER_HH
 
 #include "KronVector.hh"
 #include "QuasiTriangular.hh"
@@ -113,4 +113,4 @@ private:
   static constexpr double diag_zero_sq = diag_zero * diag_zero;
 };
 
-#endif /* TRIANGULAR_SYLVESTER_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/Vector.hh b/mex/sources/libkorder/sylv/Vector.hh
index 49b2f892f..1168ff0bb 100644
--- a/mex/sources/libkorder/sylv/Vector.hh
+++ b/mex/sources/libkorder/sylv/Vector.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef VECTOR_H
-#define VECTOR_H
+#ifndef VECTOR_HH
+#define VECTOR_HH
 
 /* NOTE: Vector and ConstVector have not common super class in order
    to avoid running virtual method invokation mechanism. Some
@@ -251,4 +251,4 @@ public:
   void print() const;
 };
 
-#endif /* VECTOR_H */
+#endif
diff --git a/mex/sources/libkorder/sylv/tests/MMMatrix.hh b/mex/sources/libkorder/sylv/tests/MMMatrix.hh
index b08f41276..67985f710 100644
--- a/mex/sources/libkorder/sylv/tests/MMMatrix.hh
+++ b/mex/sources/libkorder/sylv/tests/MMMatrix.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef MM_MATRIX_H
-#define MM_MATRIX_H
+#ifndef MM_MATRIX_HH
+#define MM_MATRIX_HH
 
 #include "GeneralMatrix.hh"
 
@@ -79,4 +79,4 @@ public:
   static void write(const std::string& fname, const GeneralMatrix& m);
 };
 
-#endif /* MM_MATRIX_H */
+#endif
diff --git a/mex/sources/libkorder/tl/equivalence.hh b/mex/sources/libkorder/tl/equivalence.hh
index df639c519..1ff89fc77 100644
--- a/mex/sources/libkorder/tl/equivalence.hh
+++ b/mex/sources/libkorder/tl/equivalence.hh
@@ -50,8 +50,8 @@
    classes according to their averages, and according to the smallest
    equivalence class element if the averages are the same. */
 
-#ifndef EQUIVALENCE_H
-#define EQUIVALENCE_H
+#ifndef EQUIVALENCE_HH
+#define EQUIVALENCE_HH
 
 #include "int_sequence.hh"
 
diff --git a/mex/sources/libkorder/tl/fine_container.hh b/mex/sources/libkorder/tl/fine_container.hh
index b71f8c290..d2a07f33b 100644
--- a/mex/sources/libkorder/tl/fine_container.hh
+++ b/mex/sources/libkorder/tl/fine_container.hh
@@ -42,8 +42,8 @@
    similar thing for tensor multidimensional index. Thus, the abstraction
    is not currently used, but it might be useful in future. */
 
-#ifndef FINE_CONTAINER_H
-#define FINE_CONTAINER_H
+#ifndef FINE_CONTAINER_HH
+#define FINE_CONTAINER_HH
 
 #include "stack_container.hh"
 
diff --git a/mex/sources/libkorder/tl/fs_tensor.hh b/mex/sources/libkorder/tl/fs_tensor.hh
index 5bb9554b1..2aaa6099a 100644
--- a/mex/sources/libkorder/tl/fs_tensor.hh
+++ b/mex/sources/libkorder/tl/fs_tensor.hh
@@ -24,8 +24,8 @@
    tensors from here are identifying the multidimensional index with
    columns. */
 
-#ifndef FS_TENSOR_H
-#define FS_TENSOR_H
+#ifndef FS_TENSOR_HH
+#define FS_TENSOR_HH
 
 #include "int_power.hh"
 #include "symmetry.hh"
diff --git a/mex/sources/libkorder/tl/gs_tensor.hh b/mex/sources/libkorder/tl/gs_tensor.hh
index ebc0a71fd..966ecb111 100644
--- a/mex/sources/libkorder/tl/gs_tensor.hh
+++ b/mex/sources/libkorder/tl/gs_tensor.hh
@@ -34,8 +34,8 @@
    also by number of variables for each group. This is dealt in the class
    for tensor dimensions defined also here. */
 
-#ifndef GS_TENSOR_H
-#define GS_TENSOR_H
+#ifndef GS_TENSOR_HH
+#define GS_TENSOR_HH
 
 #include "fs_tensor.hh"
 #include "rfs_tensor.hh"
diff --git a/mex/sources/libkorder/tl/int_sequence.hh b/mex/sources/libkorder/tl/int_sequence.hh
index 33101668e..d43d82d8e 100644
--- a/mex/sources/libkorder/tl/int_sequence.hh
+++ b/mex/sources/libkorder/tl/int_sequence.hh
@@ -39,8 +39,8 @@
 
    Also, we need to construct a subsequence of a sequence. */
 
-#ifndef INT_SEQUENCE_H
-#define INT_SEQUENCE_H
+#ifndef INT_SEQUENCE_HH
+#define INT_SEQUENCE_HH
 
 #include <algorithm>
 #include <initializer_list>
diff --git a/mex/sources/libkorder/tl/kron_prod.hh b/mex/sources/libkorder/tl/kron_prod.hh
index 106a7404f..f76e1621d 100644
--- a/mex/sources/libkorder/tl/kron_prod.hh
+++ b/mex/sources/libkorder/tl/kron_prod.hh
@@ -37,8 +37,8 @@
    For this multiplication, we also need to represent products of type A⊗I,
    I⊗A⊗I and I⊗A. */
 
-#ifndef KRON_PROD_H
-#define KRON_PROD_H
+#ifndef KRON_PROD_HH
+#define KRON_PROD_HH
 
 #include <memory>
 #include <utility>
diff --git a/mex/sources/libkorder/tl/normal_moments.hh b/mex/sources/libkorder/tl/normal_moments.hh
index 856a2fbc4..909457ab5 100644
--- a/mex/sources/libkorder/tl/normal_moments.hh
+++ b/mex/sources/libkorder/tl/normal_moments.hh
@@ -113,8 +113,8 @@
    exactly 2 elements.
 */
 
-#ifndef NORMAL_MOMENTS_H
-#define NORMAL_MOMENTS_H
+#ifndef NORMAL_MOMENTS_HH
+#define NORMAL_MOMENTS_HH
 
 #include "t_container.hh"
 
diff --git a/mex/sources/libkorder/tl/permutation.hh b/mex/sources/libkorder/tl/permutation.hh
index 3995f0ece..a799532a0 100644
--- a/mex/sources/libkorder/tl/permutation.hh
+++ b/mex/sources/libkorder/tl/permutation.hh
@@ -45,8 +45,8 @@
    which contains all permutation sets up to a given number.
 */
 
-#ifndef PERMUTATION_H
-#define PERMUTATION_H
+#ifndef PERMUTATION_HH
+#define PERMUTATION_HH
 
 #include "equivalence.hh"
 #include "int_sequence.hh"
diff --git a/mex/sources/libkorder/tl/ps_tensor.hh b/mex/sources/libkorder/tl/ps_tensor.hh
index 8ea80a52e..143ca2a34 100644
--- a/mex/sources/libkorder/tl/ps_tensor.hh
+++ b/mex/sources/libkorder/tl/ps_tensor.hh
@@ -54,8 +54,8 @@
    dimensions is described by PerTensorDimens2. The tensor holding the
    underlying data is FPSTensor. */
 
-#ifndef PS_TENSOR_H
-#define PS_TENSOR_H
+#ifndef PS_TENSOR_HH
+#define PS_TENSOR_HH
 
 #include "equivalence.hh"
 #include "gs_tensor.hh"
diff --git a/mex/sources/libkorder/tl/pyramid_prod.hh b/mex/sources/libkorder/tl/pyramid_prod.hh
index 1372e3ef9..041504114 100644
--- a/mex/sources/libkorder/tl/pyramid_prod.hh
+++ b/mex/sources/libkorder/tl/pyramid_prod.hh
@@ -66,8 +66,8 @@
    implemented in FGSContainer::multAndAdd() unfolded code or
    FGSContainer::multAndAdd() folded code. */
 
-#ifndef PYRAMID_PROD_H
-#define PYRAMID_PROD_H
+#ifndef PYRAMID_PROD_HH
+#define PYRAMID_PROD_HH
 
 #include "gs_tensor.hh"
 #include "int_sequence.hh"
diff --git a/mex/sources/libkorder/tl/pyramid_prod2.hh b/mex/sources/libkorder/tl/pyramid_prod2.hh
index 3ba186363..f741f702a 100644
--- a/mex/sources/libkorder/tl/pyramid_prod2.hh
+++ b/mex/sources/libkorder/tl/pyramid_prod2.hh
@@ -67,8 +67,8 @@
    only through the ‘index’. Note that this does not matter, since
    [f_zˡ] are sparse. */
 
-#ifndef PYRAMID_PROD2_H
-#define PYRAMID_PROD2_H
+#ifndef PYRAMID_PROD2_HH
+#define PYRAMID_PROD2_HH
 
 #include "permutation.hh"
 #include "rfs_tensor.hh"
diff --git a/mex/sources/libkorder/tl/rfs_tensor.hh b/mex/sources/libkorder/tl/rfs_tensor.hh
index 851d99470..f08f4c345 100644
--- a/mex/sources/libkorder/tl/rfs_tensor.hh
+++ b/mex/sources/libkorder/tl/rfs_tensor.hh
@@ -52,8 +52,8 @@
    implement getOffset(). Process of unfolding is not used, so we implemented
    it so that unfolding and then folding a tensor would yield the same data. */
 
-#ifndef RFS_TENSOR_H
-#define RFS_TENSOR_H
+#ifndef RFS_TENSOR_HH
+#define RFS_TENSOR_HH
 
 #include "fs_tensor.hh"
 #include "symmetry.hh"
diff --git a/mex/sources/libkorder/tl/sparse_tensor.hh b/mex/sources/libkorder/tl/sparse_tensor.hh
index e2604aed1..b04ab17cf 100644
--- a/mex/sources/libkorder/tl/sparse_tensor.hh
+++ b/mex/sources/libkorder/tl/sparse_tensor.hh
@@ -39,8 +39,8 @@
    the only constructor of general symmetry sparse tensor is slicing from
    the full symmetry sparse. */
 
-#ifndef SPARSE_TENSOR_H
-#define SPARSE_TENSOR_H
+#ifndef SPARSE_TENSOR_HH
+#define SPARSE_TENSOR_HH
 
 #include "Vector.hh"
 #include "gs_tensor.hh"
diff --git a/mex/sources/libkorder/tl/stack_container.hh b/mex/sources/libkorder/tl/stack_container.hh
index 9b3496bde..30a2e9806 100644
--- a/mex/sources/libkorder/tl/stack_container.hh
+++ b/mex/sources/libkorder/tl/stack_container.hh
@@ -75,8 +75,8 @@
    We have also two supporting classes StackProduct and KronProdStack
    and a number of worker classes used as threads. */
 
-#ifndef STACK_CONTAINER_H
-#define STACK_CONTAINER_H
+#ifndef STACK_CONTAINER_HH
+#define STACK_CONTAINER_HH
 
 #include "equivalence.hh"
 #include "int_sequence.hh"
diff --git a/mex/sources/libkorder/tl/symmetry.hh b/mex/sources/libkorder/tl/symmetry.hh
index 4750aa115..b5b1c51ba 100644
--- a/mex/sources/libkorder/tl/symmetry.hh
+++ b/mex/sources/libkorder/tl/symmetry.hh
@@ -48,8 +48,8 @@
    The symmetry is implemented as IntSequence, in fact, it inherits
    from it. */
 
-#ifndef SYMMETRY_H
-#define SYMMETRY_H
+#ifndef SYMMETRY_HH
+#define SYMMETRY_HH
 
 #include "equivalence.hh"
 #include "int_sequence.hh"
diff --git a/mex/sources/libkorder/tl/t_container.hh b/mex/sources/libkorder/tl/t_container.hh
index 8adb19acc..7f5f41b9a 100644
--- a/mex/sources/libkorder/tl/t_container.hh
+++ b/mex/sources/libkorder/tl/t_container.hh
@@ -58,8 +58,8 @@
    multiplied by folded tensors g yielding folded tensor B, but unfolded tensor
    h is multiplied by unfolded tensors g yielding unfolded tensor B. */
 
-#ifndef T_CONTAINER_H
-#define T_CONTAINER_H
+#ifndef T_CONTAINER_HH
+#define T_CONTAINER_HH
 
 #include "Vector.hh"
 #include "equivalence.hh"
diff --git a/mex/sources/libkorder/tl/t_polynomial.hh b/mex/sources/libkorder/tl/t_polynomial.hh
index 800348dc6..058344ac5 100644
--- a/mex/sources/libkorder/tl/t_polynomial.hh
+++ b/mex/sources/libkorder/tl/t_polynomial.hh
@@ -51,6 +51,9 @@
    compactification of the polynomial. The class derives from the tensor
    and has a eval method. */
 
+#ifndef T_POLYNOMIAL_HH
+#define T_POLYNOMIAL_HH
+
 #include "fs_tensor.hh"
 #include "pascal_triangle.hh"
 #include "rfs_tensor.hh"
@@ -555,3 +558,5 @@ public:
   {
   }
 };
+
+#endif
diff --git a/mex/sources/libkorder/tl/tensor.hh b/mex/sources/libkorder/tl/tensor.hh
index 74ee6423e..5a326a4fa 100644
--- a/mex/sources/libkorder/tl/tensor.hh
+++ b/mex/sources/libkorder/tl/tensor.hh
@@ -57,8 +57,8 @@
    objects are not used very often. They have limited usage due to their
    specialized constructor. */
 
-#ifndef TENSOR_H
-#define TENSOR_H
+#ifndef TENSOR_HH
+#define TENSOR_HH
 
 #include "int_sequence.hh"
 #include "twod_matrix.hh"
diff --git a/mex/sources/libkorder/tl/tests/factory.hh b/mex/sources/libkorder/tl/tests/factory.hh
index b369c2404..a3cf7cef6 100644
--- a/mex/sources/libkorder/tl/tests/factory.hh
+++ b/mex/sources/libkorder/tl/tests/factory.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef FACTORY_H
-#define FACTORY_H
+#ifndef FACTORY_HH
+#define FACTORY_HH
 
 #include <memory>
 #include <random>
diff --git a/mex/sources/libkorder/tl/tests/monoms.hh b/mex/sources/libkorder/tl/tests/monoms.hh
index 55dfcc212..d4523f291 100644
--- a/mex/sources/libkorder/tl/tests/monoms.hh
+++ b/mex/sources/libkorder/tl/tests/monoms.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef MONOMS_H
-#define MONOMS_H
+#ifndef MONOMS_HH
+#define MONOMS_HH
 
 #include <memory>
 #include <random>
diff --git a/mex/sources/libkorder/tl/tl_exception.hh b/mex/sources/libkorder/tl/tl_exception.hh
index b67441518..ff5adc806 100644
--- a/mex/sources/libkorder/tl/tl_exception.hh
+++ b/mex/sources/libkorder/tl/tl_exception.hh
@@ -27,8 +27,8 @@
    some higher level. This header file defines a simple infrastructure
    for this. */
 
-#ifndef TL_EXCEPTION_H
-#define TL_EXCEPTION_H
+#ifndef TL_EXCEPTION_HH
+#define TL_EXCEPTION_HH
 
 #include <iostream>
 #include <string>
diff --git a/mex/sources/libkorder/tl/tl_static.hh b/mex/sources/libkorder/tl/tl_static.hh
index 55a1aef00..07cd05372 100644
--- a/mex/sources/libkorder/tl/tl_static.hh
+++ b/mex/sources/libkorder/tl/tl_static.hh
@@ -29,8 +29,8 @@
    TLStatic::init() must be called at the beginning of the program, as
    soon as dimension and number of variables is known. */
 
-#ifndef TL_STATIC_H
-#define TL_STATIC_H
+#ifndef TL_STATIC_HH
+#define TL_STATIC_HH
 
 #include "equivalence.hh"
 #include "permutation.hh"
diff --git a/mex/sources/libkorder/tl/twod_matrix.hh b/mex/sources/libkorder/tl/twod_matrix.hh
index 23998e1f5..7c53e661e 100644
--- a/mex/sources/libkorder/tl/twod_matrix.hh
+++ b/mex/sources/libkorder/tl/twod_matrix.hh
@@ -29,8 +29,8 @@
    ConstTwoDMatrix. The only purpose of the latter is to allow submatrix
    construction from const reference arguments. */
 
-#ifndef TWOD_MATRIX_H
-#define TWOD_MATRIX_H
+#ifndef TWOD_MATRIX_HH
+#define TWOD_MATRIX_HH
 
 #include "GeneralMatrix.hh"
 
diff --git a/mex/sources/libkorder/utils/dynare_exception.hh b/mex/sources/libkorder/utils/dynare_exception.hh
index 6e4fc370e..2e105a9a6 100644
--- a/mex/sources/libkorder/utils/dynare_exception.hh
+++ b/mex/sources/libkorder/utils/dynare_exception.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef DYNARE_EXCEPTION_H
-#define DYNARE_EXCEPTION_H
+#ifndef DYNARE_EXCEPTION_HH
+#define DYNARE_EXCEPTION_HH
 
 #include <string>
 #include <utility>
diff --git a/mex/sources/libkorder/utils/exception.hh b/mex/sources/libkorder/utils/exception.hh
index cb04df44e..d726743b5 100644
--- a/mex/sources/libkorder/utils/exception.hh
+++ b/mex/sources/libkorder/utils/exception.hh
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef OGU_EXCEPTION_H
-#define OGU_EXCEPTION_H
+#ifndef EXCEPTION_HH
+#define EXCEPTION_HH
 
 #include <iostream>
 #include <string>
diff --git a/mex/sources/libkorder/utils/int_power.hh b/mex/sources/libkorder/utils/int_power.hh
index 4c647c832..4668d191d 100644
--- a/mex/sources/libkorder/utils/int_power.hh
+++ b/mex/sources/libkorder/utils/int_power.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -17,5 +17,10 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#ifndef INT_POWER_HH
+#define INT_POWER_HH
+
 // Integer exponentiation (by squaring)
 int power(int a, int b);
+
+#endif
diff --git a/mex/sources/libkorder/utils/pascal_triangle.hh b/mex/sources/libkorder/utils/pascal_triangle.hh
index 736a46b0d..e93d2f7be 100644
--- a/mex/sources/libkorder/utils/pascal_triangle.hh
+++ b/mex/sources/libkorder/utils/pascal_triangle.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2005 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -18,8 +18,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef PASCAL_TRIANGLE_H
-#define PASCAL_TRIANGLE_H
+#ifndef PASCAL_TRIANGLE_HH
+#define PASCAL_TRIANGLE_HH
 
 #include <vector>
 
diff --git a/mex/sources/libkorder/utils/sthread.hh b/mex/sources/libkorder/utils/sthread.hh
index 77813a57f..70a76aead 100644
--- a/mex/sources/libkorder/utils/sthread.hh
+++ b/mex/sources/libkorder/utils/sthread.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -38,8 +38,8 @@
    The number of maximum parallel threads is controlled via a static member of
    the detach_thread_group class. */
 
-#ifndef STHREAD_H
-#define STHREAD_H
+#ifndef STHREAD_HH
+#define STHREAD_HH
 
 #include <condition_variable>
 #include <map>
diff --git a/mex/sources/ms-sbvar/modify_for_mex.h b/mex/sources/ms-sbvar/modify_for_mex.h
index 27f18432b..e5655fdf6 100644
--- a/mex/sources/ms-sbvar/modify_for_mex.h
+++ b/mex/sources/ms-sbvar/modify_for_mex.h
@@ -17,8 +17,8 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef _MODIFY_FOR_MEX_H
-#define _MODIFY_FOR_MEX_H
+#ifndef MODIFY_FOR_MEX_H
+#define MODIFY_FOR_MEX_H
 
 #include <dynblas.h>
 #include <dynlapack.h>
@@ -56,4 +56,4 @@ _Noreturn
     void
     msExit(int status);
 
-#endif // _MODIFY_FOR_MEX_H
+#endif
diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
index b157c2c6e..d4891e57c 100644
--- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
+++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
@@ -17,6 +17,9 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#ifndef DYNAMIC_MODEL_CALLER_HH
+#define DYNAMIC_MODEL_CALLER_HH
+
 #include <algorithm>
 #include <limits>
 #include <memory>
@@ -185,3 +188,5 @@ DynamicModelMatlabCaller::cmplxToReal(mxArray* cmplx_mx)
   mxDestroyArray(cmplx_mx);
   return real_mx;
 }
+
+#endif
diff --git a/mex/sources/sobol/gaussian.hh b/mex/sources/sobol/gaussian.hh
index 12af57a3e..4e709cccd 100644
--- a/mex/sources/sobol/gaussian.hh
+++ b/mex/sources/sobol/gaussian.hh
@@ -22,6 +22,9 @@
 ** AUTHOR(S): stephane DOT adjemian AT univ DASH lemans DOT fr
 */
 
+#ifndef GAUSSIAN_HH
+#define GAUSSIAN_HH
+
 #include <algorithm>
 #include <array>
 #include <cmath>
@@ -162,3 +165,5 @@ usphereRadius(int d, int n, double radius, T* U)
         U[k + i] = radius * U[k + i] / norm;
     }
 }
+
+#endif
diff --git a/mex/sources/sobol/sobol.hh b/mex/sources/sobol/sobol.hh
index 2531d40f6..026ccfa26 100644
--- a/mex/sources/sobol/sobol.hh
+++ b/mex/sources/sobol/sobol.hh
@@ -18,6 +18,9 @@
  * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#ifndef SOBOL_HH
+#define SOBOL_HH
+
 #include <cstdint>
 #include <dynblas.h> // For the FORTRAN_WRAPPER macro
 
@@ -63,3 +66,5 @@ expand_unit_hypercube(int dimension, int block_size, T* block, const T* lower_bo
     }
   delete[] hypercube_length;
 }
+
+#endif
-- 
GitLab