SDK compiler vs gcc
Afficher commentaires plus anciens
I have an example where I want to create a vector of doubles of a size given by a variable i pass to a function within a mex function (double V[] and then fill it out using a loop). The code is compiled and works as expected with gcc compiler on a linux machine. However, when I try to compile the code on a 32 bits windows machine using a SDK compiler the line double V[] causes a few errors.
This is the code: **************************************************************** // #include matrix.h #include mex.h
void comp_routine(double c[],const int s){ int i; double V[s-1]; // this line doesn't cause trouble in gcc compiler // double V[10]; for (i=0;i<s;i++){ V[i]=i; }
for (i=0;i<s;i++){
c[i]=V[i]=i;
}
return;
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
//declare variables
mxArray *a_in_m, *c_out_m;
double *a,*c;
//associate inputs a_in_m = mxDuplicateArray(prhs[0]);
//associate pointers a = mxGetPr(a_in_m); int s = (int) a[0];
//associate outputs
c_out_m = plhs[0] = mxCreateDoubleMatrix(s,1,mxREAL);
c = mxGetPr(c_out_m);
comp_routine(c,s);
return;
}
**************************************************************
And these are the errors i receive:
>> mex sdk_vs_gcc.cpp sdk_vs_gcc.cpp sdk_vs_gcc.cpp(6) : error C2057: expected constant expression sdk_vs_gcc.cpp(6) : error C2466: cannot allocate an array of constant size 0 sdk_vs_gcc.cpp(6) : error C2133: 'V' : unknown size
C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Compile of 'sdk_vs_gcc.cpp' failed.
Thank you for help!
1 commentaire
Jan
le 10 Sep 2013
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB Compiler SDK dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!