This example shows how to set the maximum stack space that the generated code uses. Set the maximum stack usage when:
You have limited stack space, for instance, in embedded targets.
Your C compiler reports a run-time stack overflow.
The value of the property, StackUsageMax
,
is measured in bytes. Based on information from the target hardware
settings, the software estimates the number of stack variables that
a certain value of StackUsageMax
can accommodate.
This estimate excludes possible C compiler optimizations such as putting
variables in registers.
To open the Generate dialog
box, on the Generate Code page, click the Generate arrow .
Set Build type to Source
Code
, Static Library
, Dynamic
Library
, or Executable
(depending
on your requirements).
Click More Settings.
On the Memory tab, set Stack usage max to the value that you want.
Create a configuration object for code generation.
Use coder.config
with arguments 'lib'
,'dll'
,
or 'exe'
(depending on your requirements). For
example:
cfg = coder.config('lib');
Set the property, StackUsageMax
,
to the value that you want.
cfg.StackUsageMax=400000;