MS-SBVAR MEX: fixes related to C linkage (extern "C")

Also fix or remove various #ifdefs, and remove unused “int constant_seed”.
kalman-mex
Sébastien Villemot 2023-09-22 13:28:13 +02:00
parent 4a68cfcbd6
commit 4f1e5e1bc2
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 27 additions and 37 deletions

View File

@ -17,25 +17,12 @@
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/ */
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
#include <dynmex.h> #include <dynmex.h>
# ifdef __cplusplus
extern "C" extern "C"
{
# endif
int constant_seed;
[[noreturn]] [[noreturn]]
void void
msExit([[maybe_unused]] int status) msExit([[maybe_unused]] int status)
{ {
throw "Error in MS-SBVAR MEX file.\n"; throw "Error in MS-SBVAR MEX file.\n";
} }
# ifdef __cplusplus
}
# endif
#endif

View File

@ -17,10 +17,8 @@
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef _MEXMOD #ifndef _MODIFY_FOR_MEX_H
#define _MEXMOD #define _MODIFY_FOR_MEX_H
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
#include <dynmex.h> #include <dynmex.h>
#include <dynblas.h> #include <dynblas.h>
@ -34,11 +32,19 @@
/* Handle Ctrl-C in Matlab/Octave */ /* Handle Ctrl-C in Matlab/Octave */
#ifdef MATLAB_MEX_FILE #ifdef MATLAB_MEX_FILE
extern bool utIsInterruptPending(); # ifdef __cplusplus
extern "C"
# else
extern
# endif
bool utIsInterruptPending();
#else #else
# include <octave/quit.h> # include <octave/quit.h>
#endif #endif
#ifdef __cplusplus
extern "C"
#endif
// NB: C23 has the [[noreturn]] attribute, so this #ifdef can be removed when // NB: C23 has the [[noreturn]] attribute, so this #ifdef can be removed when
// we upgrade // we upgrade
#ifdef __cplusplus #ifdef __cplusplus
@ -48,7 +54,4 @@ _Noreturn
#endif #endif
void msExit(int status); void msExit(int status);
extern int constant_seed; #endif // _MODIFY_FOR_MEX_H
#endif
#endif