フィルターのクリア

Strange MEX Compile Issue

14 ビュー (過去 30 日間)
Rowan Lawrence
Rowan Lawrence 2020 年 2 月 28 日
コメント済み: Rowan Lawrence 2020 年 2 月 28 日
I am currently using MATLAB 2019a (Research Licence) and am writing some MEX utility functions.
I have finished a couple of scripts today which compiled this morning, and I have used them a handful of times since. I started to work on another script for myself and am getting an unusual error when I attempt to compile:
>> mex sum_3D.c
Building with 'MinGW64 Compiler (C)'.
Error using mex
C:\Work\MY_Utilities\sum_3D.c:12:6: error: conflicting types for 'mexFunction'
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
^~~~~~~~~~~
In file included from C:\Work\MY_Utilities\sum_3D.c:1:0:
C:\Program Files\MATLAB\R2019a/extern/include/mex.h:356:6: note: previous declaration of 'mexFunction' was here
void mexFunction(
I'm storing all my working data, etc. in
'C:\Work\'
and I have write permissions to it. I've stripped all the code I was writing out of the sum_3D.c file so tha now it just loks like this:
// Sum tissue values over each slice of a 3D matrix
#include <mex.h>
#include <matrix.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void exit_now(char *err_text)
{
mexErrMsgTxt(err_text);
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
exit_now("\nTest.\n");
}
Confusingly, the code I used this morning which is kept in the same folder and has the exact same declarations/header files/mexFunction arguments etc. recompiles successfully! I've closed down MATLAB multiple times and done a cold boot and it has not solved the problem (which, lets be honest, it usually does). Does anybody know what could be causing this?
Thanks in advance.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 2 月 28 日
Rowan - if you open the file C:\Program Files\MATLAB\R2019a/extern/include/mex.h, what is the signature for mexFunction? Is it identical to
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
?
Rowan Lawrence
Rowan Lawrence 2020 年 2 月 28 日
Hi Geoff,
Yes, the entry-point signature is:
void mexFunction(
int nlhs, /* number of expected outputs */
mxArray *plhs[], /* array of pointers to output arguments */
int nrhs, /* number of inputs */
const mxArray *prhs[] /* array of pointers to input arguments */
);
I've actually 'solved' it; I changed to what I thought was the old syntax and it now works:
void mexFunction(int nargout, mxArray *pargout[], int nargin, const mxArray *pargin[])
{
/* */
}
I also changed the argument names back to those shown in the 'mex.h' file for both this code and one of the working files I compiled this morning. Everything is working fine now. I could not be more confused.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by