Skip to main content

IAR Embedded Workbench for RX 5.20

Summary of pragma directives

In this section:

The #pragma directive is defined by Standard C and is a mechanism for using vendor-specific extensions in a controlled way to make sure that the source code is still portable.

The pragma directives control the behavior of the compiler, for example, how it allocates memory for variables and functions, whether it allows extended keywords, and whether it outputs warning messages.

The pragma directives are always enabled in the compiler.

This table lists the pragma directives of the compiler that can be used either with the #pragma preprocessor directive or the _Pragma() preprocessor operator:

Pragma directive

Description

bank

Saves the values of registers immediately before an interrupt function.

bitfields

Controls the order of bitfield members.

calls

Lists possible called functions for indirect calls.

call_graph_root

Specifies that the function is a call graph root.

cstat_disable

See the C-STAT® Static Analysis Guide.

cstat_enable

See the C-STAT® Static Analysis Guide.

cstat_restore

See the C-STAT® Static Analysis Guide.

cstat_suppress

See the C-STAT® Static Analysis Guide.

data_alignment

Gives a variable a higher (more strict) alignment.

default_function_attributes

Sets default type and object attributes for declarations and definitions of functions.

default_no_bounds

Applies #pragma no_bounds to a whole set of functions and variables. See #pragma default_no_bounds.

default_variable_attributes

Sets default type and object attributes for declarations and definitions of variables.

define_with_bounds

Instruments a function to track pointer bounds. See #pragma define_with_bounds.

define_without_bounds

Defines the version of a function that does not have extra bounds information. See #pragma define_without_bounds.

deprecated

Marks an entity as deprecated.

diag_default

Changes the severity level of diagnostic messages.

diag_error

Changes the severity level of diagnostic messages.

diag_remark

Changes the severity level of diagnostic messages.

diag_suppress

Suppresses diagnostic messages.

diag_warning

Changes the severity level of diagnostic messages.

disable_check

Specifies that the immediately following function does not check accesses against bounds. See #pragma disable_check.

error

Signals an error while parsing.

function_category

Declares function categories for stack usage analysis.

generate_entry_without_bounds

Enables generation of an extra entry without bounds for the immediately following function. See #pragma generate_entry_without_bounds.

include_alias

Specifies an alias for an include file.

inline

Controls inlining of a function.

language

Controls the IAR language extensions.

location

Specifies the absolute address of a variable, or places groups of functions or variables in named sections.

message

Prints a message.

no_arith_checks

Specifies that no C-RUN arithmetic checks will be performed in the following function. See #pragma no_arith_checks.

no_bounds

Specifies that the immediately following function or variable is not instrumented for bounds checking. See #pragma no_bounds.

no_stack_protect

Disables stack protection for the following function.

object_attribute

Adds object attributes to the declaration or definition of a variable or function.

once

Prevents a header file from being processed more than once.

optimize

Specifies the type and level of an optimization.

pack

Specifies the alignment of structures and union members.

__printf_args

Verifies that a function with a printf-style format string is called with the correct arguments.

public_equ

Defines a public assembler label and gives it a value.

required

Ensures that a symbol that is needed by another symbol is included in the linked output.

rtmodel

Adds a runtime model attribute to the module.

__scanf_args

Verifies that a function with a scanf-style format string is called with the correct arguments.

section

Declares a section name to be used by intrinsic functions.

segment

This directive is an alias for #pragma section.

stack_protect

Forces stack protection for the function that follows.

STDC CX_LIMITED_RANGE

Specifies whether the compiler can use normal complex mathematical formulas or not.

STDC FENV_ACCESS

Specifies whether your source code accesses the floating-point environment or not.

STDC FP_CONTRACT

Specifies whether the compiler is allowed to contract floating-point expressions or not.

type_attribute

Adds type attributes to a declaration or to definitions.

unroll

Unrolls loops.

vector

Specifies the vector of an interrupt or trap function.

weak

Makes a definition a weak definition, or creates a weak alias for a function or a variable.

Table 81. Pragma directives summary 


Note

For portability reasons, see also Recognized pragma directives (6.10.6).