Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex: Compile error with mxArray
Date: Fri, 14 Aug 2009 06:39:01 +0000 (UTC)
Organization: Boeing
Lines: 35
Message-ID: <h630q5$o5b$1@fred.mathworks.com>
References: <h61543$anv$1@fred.mathworks.com> <h619lq$hka$1@fred.mathworks.com> <h61acj$43k$1@fred.mathworks.com> <h61iba$hft$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250231941 24747 172.30.248.38 (14 Aug 2009 06:39:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Aug 2009 06:39:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:563316


"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <h61iba$hft$1@fred.mathworks.com>...
> "David  Hanau" <hanaud@gmail.com.REMTHIS> wrote in message <h61acj$43k$1@fred.mathworks.com>...
> > 
> > This code works and the last releave of MatLab bur not on my V6.1
> > I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.
>                :
> > 	mexEvalString("options.disp=0;");           // for use in calling Matlab function eigs	
> > 	mexEvalString("options.maxit=500;");		 // for use in calling Matlab function eigs	
> > 	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs
> > 	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);
> > 	input[2]= mxCreateString("la");
> > 	input[3]= mexGetVariable("caller","options");
>                     :
> 
> I don't have a v6.1 available, but my guess is that one or more of your mx___ or mex___ functions is not available in the older MATLAB version. If it is not available, then there will be no prototype in the mex.h or matrix.h file. So when the compiler gets to the function, absent a prototype, it makes the default assumption that the function returns an int, and of course you are assigning it to a mxArray *. Thus you get the "... invalid assignment int to mxArray * ..." message from the compiler.
> 
> My advice is to get a list of all the mx___ and mex___ functions you use and check to see which ones are not available in the earlier version of MATLAB, and then write workarounds for these functions if you can.
> 

Looks like the culprit is indeed mexGetVariable. The older MATLAB versions have a different function called mexGetArray. The comparison prototypes are:

Older versions:
mxArray *mexGetArray(const char *name, const char *workspace);

Newer versions:
mxArray *mexGetVariable(const char *workspace, const char *varname);

So the name is different, and the argument order has switched. So include this at the top of your source code when compiling using the older version of MATLAB:

mxArray *mexGetVariable(const char *workspace, const char *varname)
{
    return mexGetArray(varname, workspace);
}

James Tursa