StackOverflow exception when using Matlab Coder ?
4 views (last 30 days)
Show older comments
Baptiste PERRIN
on 22 Mar 2016
Answered: Baptiste PERRIN
on 31 Mar 2016
Hello,
I'm a new user of Matlab Coder and I try to translate my Matlab code in C. My matlab code uses the Image toolbox, and in the entry-point function, I have a buffer of 1920*1080 pixels. So, when I generate the C code, the function has "const unsigned int buffer[2073600]" as an entry-point and I think that is the cause of the exception. So, how can I said to matlab coder to not write in the stack and take a pointer in entry-point ? Thank you for this community,
Baptiste
1 Comment
Accepted Answer
More Answers (1)
Vidya Viswanathan
on 31 Mar 2016
Hi Baptiste,
As per my understanding, arrays are always passed by reference in C programming (by default). For example, consider the following code that is generated from a MATLAB function that accepts a matrix of size 1920 x 1080 as input and returns a matrix of the same size:
void MultBy2(const double u[2073600], double y[2073600])
{
int i0;
for (i0 = 0; i0 < 2073600; i0++) {
y[i0] = u[i0] * 2.0;
}
}
Although the argument in the function is of the form "const double u[2073600]" rather than "const double* u[2073600]", the function that calls "MultBy2" (after creating an array of dimensions 1920 x 1080 and passing the name of the array) would still pass the array by reference (because the name of the array is a pointer to the first location of the array). Therefore, I feel that there would be no variable created in the stack.
I am not sure if this answers your question. I apologise if I have misunderstood your query. It would be very helpful if you could post the exact error message that you are receiving.
Regards,
Vidya
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!