Main Content

Allow right shifts on signed integers


Specify whether to allow signed right bitwise shifts in the generated C/C++ code. Some coding standards, such as MISRA, do not allow bitwise operations on signed integers. Clearing this option increases the likelihood of generating MISRA-C:2004 compliant code.

Category: Code Generation > Code Style


Default: on


Generate code that uses right bitwise shifts on signed integers.

For example, when you select this option, right shifts appear in the generated code.

i >>= 3


Do not allow right shifts on signed integers. Clearing this option supports MISRA C® compliance.

For example, when you clear this option, right shifts are replaced with a function call.

i = asr_s32(i, 3U);

Command-Line Information

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

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
Safety precautionNo impact

Related Topics