Main Content

Control use of clang format configuration

Control generation of clang-format file

Since R2021a

Description

App Configuration Pane: Code Appearance

Configuration Objects: coder.EmbeddedCodeConfig

Set this option to specify if you want to generate or use an existing clang-format file to format the generated code. For more information, see https://clang.llvm.org/docs/ClangFormatStyleOptions.html.

clang-format does not have native CUDA® C++ support. When generating CUDA code using GPU Coder™, setting the formatting tool to 'Clang-format' might result in build failures during code compilation.

Settings

Generate a new clang format configuration file

This value is the default value.

Creates a clang-format file for your build based on your configuration settings. The clang-format file is generated in the codegen folder.

Use existing clang format configuration file

Formats the generated code by using a clang-format file of your choice. Using clang-format enables detailed control over the formatting of your generated code.

The code generator searches for an existing clang-format file in the code generation folder and then the folder tree above the code generation folder. The code generator looks for files whose name includes _clang-format or is a .clang-format file that it finds. If it is unable to find the required file, the code generator uses the built-in format specification.

Programmatic Use

Property: ClangFormatFile
Values: 'Generate' | 'Existing'
Default: 'Generate'

Version History

Introduced in R2021a