Array Size Restrictions for Code Generation

For code generation, the maximum number of elements of an array is constrained by the code generator and the target hardware.

For fixed-size arrays and variable-size arrays that use static memory allocation, the maximum number of elements is the smaller of:

  • intmax('int32').

  • The largest integer that fits in the C int data type on the target hardware.

For variable-size arrays that use dynamic memory allocation, the maximum number of elements is the smaller of:

  • intmax('int32').

  • The largest power of 2 that fits in the C int data type on the target hardware.

These restrictions apply even on a 64-bit platform.

For a fixed-size array, if the number of elements exceeds the maximum, the code generator reports an error at compile time. For a variable-size array, at run time, if the number of elements exceeds the maximum and run-time error checks are enabled, the generated code reports an error. By default, run-time error checks are enabled for MEX code and disabled for standalone C/C++ code.

See Also

Related Topics