MATLAB Code Patterns That Require a Nonempty Initialize Function in Generated Code - MATLAB & Simulink (original) (raw)

Issue

When generating standalone code from MATLAB® code, you choose not to generate the initialize function:

Also, you ensure that the custom code to appear in the generated initialize function is empty:

You still get this error message:

The initialize function is not empty, but the IncludeInitializeFcn configuration setting requests that the initialize function be omitted.

Solution

In certain situations, the code generator determines that the initialize function must be nonempty and produces code for the initialize function. This code generation can occur even if the custom code for the initialize function that you specify is empty. Not including this generated code in the initialize function causes the generated entry-point functions to operate on an invalid state. In such situations, if you choose to not generate the initialize function, the code generator produces an error message.

To fix this issue, include the initialize function in your generated code by doing one of the following:

Examples of MATLAB code patterns that require a nonempty initialize function in the generated code are:

#include "foo_initialize.h"
#include "foo.h"
#include "foo_data.h"
#include "rt_nonfinite.h"
/* Function Definitions /
/

#include "bar_initialize.h"
#include "bar.h"
#include "bar_data.h"
/* Function Definitions /
/

See Also

coder.EmbeddedCodeConfig