diff --git a/mex/sources/ms-sbvar/modify_for_mex.cc b/mex/sources/ms-sbvar/modify_for_mex.cc index 2e32ae40a..52206e073 100644 --- a/mex/sources/ms-sbvar/modify_for_mex.cc +++ b/mex/sources/ms-sbvar/modify_for_mex.cc @@ -17,25 +17,12 @@ * along with Dynare. If not, see . */ -#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) +#include -# include - -# ifdef __cplusplus extern "C" +[[noreturn]] +void +msExit([[maybe_unused]] int status) { -# endif - - int constant_seed; - - [[noreturn]] - void - msExit([[maybe_unused]] int status) - { - throw "Error in MS-SBVAR MEX file.\n"; - } - -# ifdef __cplusplus + throw "Error in MS-SBVAR MEX file.\n"; } -# endif -#endif diff --git a/mex/sources/ms-sbvar/modify_for_mex.h b/mex/sources/ms-sbvar/modify_for_mex.h index 973fa425f..3fcb78b4d 100644 --- a/mex/sources/ms-sbvar/modify_for_mex.h +++ b/mex/sources/ms-sbvar/modify_for_mex.h @@ -17,28 +17,34 @@ * along with Dynare. If not, see . */ -#ifndef _MEXMOD -#define _MEXMOD +#ifndef _MODIFY_FOR_MEX_H +#define _MODIFY_FOR_MEX_H -#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) +#include +#include +#include -# include -# include -# include - -# define dw_malloc mxMalloc -# define dw_calloc mxCalloc -# define dw_realloc mxRealloc -# define dw_free mxFree -# define dw_exit msExit +#define dw_malloc mxMalloc +#define dw_calloc mxCalloc +#define dw_realloc mxRealloc +#define dw_free mxFree +#define dw_exit msExit /* Handle Ctrl-C in Matlab/Octave */ -# ifdef MATLAB_MEX_FILE -extern bool utIsInterruptPending(); +#ifdef MATLAB_MEX_FILE +# ifdef __cplusplus +extern "C" # else -# include +extern # endif +bool utIsInterruptPending(); +#else +# include +#endif +#ifdef __cplusplus +extern "C" +#endif // NB: C23 has the [[noreturn]] attribute, so this #ifdef can be removed when // we upgrade #ifdef __cplusplus @@ -48,7 +54,4 @@ _Noreturn #endif void msExit(int status); -extern int constant_seed; - -#endif -#endif +#endif // _MODIFY_FOR_MEX_H