Main Content

Preserve extern keyword in function declarations

Include extern keyword in function declarations

Model Configuration Pane: Code Generation / Code Style

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.

Settings

on (default) | off

Default: on

On

Include the extern keyword in function declarations in the generated code.

Off

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

Examples

expand all

Compare the function declarations in the generated code when you set Preserve extern keyword in function declarations to different values.

Here is generated code that generated using the default Preserve extern keyword in function declarations value off:

/* Model entry point functions */
void CounterModel_initialize(void);
void CounterModel_step(void);

Here is the same code generated with Preserve extern keyword in function declarations set to on:

/* Model entry point functions */
extern void CounterModel_initialize(void);
extern void CounterModel_step(void);
The extern keyword explicitly indicates that the function has external linkage.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

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

Version History

Introduced in R2009b