Main Content

Preserve extern keyword in function declarations

Description

Specify whether to include the extern keyword in function declarations in the generated code.

Note

The extern keyword is optional for functions with external linkage. It is considered good programming practice to include the extern keyword in function declarations for code readability.

Category: Code Generation > Code Style

Settings

Default: on

On

Include the extern keyword in function declarations in the generated code. For example, the generated code for the model rtwdemo_hyperlinks contains the following function declarations in rtwdemo_hyperlinks.h:

/* Model entry point functions */
extern void rtwdemo_hyperlinks_initialize(void);
extern void rtwdemo_hyperlinks_step(void);

The extern keyword explicitly indicates that the function has external linkage. The function definitions in this example are in the generated file rtwdemo_hyperlinks.c.

Off

Remove the extern keyword from function declarations in the generated code.

Command-Line Information

Parameter: PreserveExternInFcnDecls
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Related Topics