mex: valid c code crashes Matlab. (integer pointer)
Mostra commenti meno recenti
This code compiles, but crashes Matlab. The same code written and compiled as straight c works fine.
#include "mex.h"
#include <stdio.h>
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
//int z =11;
int *x = 1;
*x = 14;
printf("*x = %d\n", *x);
}
With this small change it works fine. Should I have expected this behavior?
#include "mex.h"
#include <stdio.h>
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
int z =11;
int *x = &z;
*x = 14;
printf("*x = %d\n", *x);
}
1 Commento
Gary Pajer
il 19 Ago 2016
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su C Shared Library Integration in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!