Contenuto principale

%#codegen (pragma)

R2026b

Pragma that Indicates a MATLAB function is intended for code generation

    Syntax

    Description

    %#codegen is a function-level pragma that instructs the MATLAB® Code Analyzer to report warnings and errors specific to code generation. Use this pragma in functions for which you intend to generate code.

    example

    Examples

    collapse all

    Add the %#codegen pragma to a function to prompt the MATLAB Code Analyzer to identify warnings and errors specific to code generation.

    function y = my_fcn(x) %#codegen
    ....

    Tips

    • You do not need to add the %#codegen pragma to functions in a MATLAB Function (Simulink) block. The Code Analyzer always reports warnings and errors specific to code generation for code in a MATLAB Function block.

    • For a list of the checks performed by the Code Analyzer when you add the %#codegen pragma, see MATLAB for Code Generation Messages.

    Version History

    Introduced in R2012b