passing argument 2 of 'mxCreateNumericArray' from incompatible pointer type

15 vues (au cours des 30 derniers jours)
Hi,
I am trying to develop a software and when I compile I have the following warning:
sin_reg.c:72:2: attention : passing argument 2 of 'mxCreateNumericArray' from incompatible pointer type [enabled by default]
In file included from /usr/local/R2011b/extern/include/mex.h:58:0,
from nmsimplex.h:33,
from sin_reg.c:2:
/usr/local/R2011b/extern/include/matrix.h:891:19: note: expected 'const mwSize *' but argument is of type 'int *'
The code is the following:
mwSize volume_dims2[3];
volume_dims2[0] = n_y;
volume_dims2[1] = 0;
volume_dims2[2] = n_x;
volume_dims2[3] = 0;
volume_dims2[4] = (mwSize) 2;
volume_dims2[5] = 0;
plhs[0] = mxCreateNumericArray((mwSize) 3, volume_dims2, mxDOUBLE_CLASS, mxREAL);
What is wrong?
Thank you for your help, Cédric

Réponse acceptée

James Tursa
James Tursa le 25 Avr 2013
Modifié(e) : James Tursa le 25 Avr 2013
Maybe you have inadvertantly redefined mwSize. Do you have the following statement somewhere at the top of your code?
#define mwSize int
This could have been used to support earlier versions of MATLAB that do not have a typedef for mwSize, for example. If so, you can get rid of it or wrap it as follows:
#ifndef MWSIZE_MAX
#define mwSize int
#endif
Also, you have only declared volume_dims2 to have 3 elements, but you are stuffing values into 6 elements ... writing beyond the array bounds which will probably result in a crash. And additionally, it looks rather weird that you are stuffing 0 into some of the elements ... is that what you really intended?

Plus de réponses (1)

Cédric Devivier
Cédric Devivier le 25 Avr 2013
I was checking for the wrong thing apparently...
#ifndef mwSize
Thank you!
For the 0 stuffs, I think it was there because I did an update of the system but did not reboot. I have rebooted and I don't need it any more.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by