Type & Object attribute

本文详细介绍了在ARM体系中使用的类型属性与对象属性的概念及其语法。类型属性定义了函数调用的方式或数据对象的访问方式,而对象属性则影响函数和数据对象的内部功能。文章还提供了使用这些属性的具体示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Type attributes

Type attributes define how a function is called, or how a data object is accessed. This means that if you use a type attribute, it must be specified both when a function or data object is defined and when it is declared.

You can either place the type attributes directly in your source code, or use the pragma directive #pragma type_attribute.

The following general type attributes are available:

    • Function type attributes affect how the function should be called: __arm, __fiq, __interwork, __irq, __swi, and __thumb
    • Data type attributes: __big_endian, const, __little_endian, __packed, and volatile

You can specify as many type attributes as required for each level of pointer indirection.

To read more about the type qualifiers const and volatile, see the IAR C/C++ Development Guide for ARM®.

Syntax for type attributes used on data objects

In general, type attributes for data objects follow the same syntax as the type qualifiers const and volatile.

The following declaration assigns the __little_endian type attribute to the variables i and j; in other words, the variables i and j will be accessed with little endian byte order. The variables k and l behave in the same way:

__little_endian int i, j; 
int __little_endian k, l; 

Note that the attribute affects both identifiers.

The following declaration of i and j is equivalent with the previous one:

#pragma type_attribute=__little_endian 
int i, j; 

The advantage of using pragma directives for specifying keywords is that it offers you a method to make sure that the source code is portable. Note that the pragma directive has no effect if a memory attribute is already explicitly declared.

Syntax for type attributes on data pointers

The syntax for declaring pointers using type attributes follows the same syntax as the type qualifiers const and volatile:

int __little_endian * p;
 
The int object will be accessed in little endian byte order.
int * __little_endian p;
 
The pointer will be accessed in little endian byte order.
__little_endian int * p;
 
The pointer will be accessed in little endian byte order.

Syntax for type attributes on functions

The syntax for using type attributes on functions differs slightly from the syntax of type attributes on data objects. For functions, the attribute must be placed either in front of the return type, or in parentheses, for example:

__irq __arm void my_handler(void); 

or

void (__irq __arm my_handler)(void); 

The following declaration of my_handler is equivalent with the previous one:

#pragma type_attribute=__irq __arm 
void my_handler(void); 
 
 

Object attributes

Object attributes affect the internal functionality of functions and data objects, but not how the function is called or how the data is accessed. This means that an object attribute does not need to be present in the declaration of an object.

The following object attributes are available:

    • Object attributes that can be used for variables: __no_init
    • Object attributes that can be used for functions and variables: location, @, __root, and __weak,
    • Object attributes that can be used for functions: __intrinsic, __nested, __noreturn, and __ramfunc.

You can specify as many object attributes as required for a specific function or data object.

For more information about location and @, see the IAR C/C++ Development Guide for ARM®.

Syntax for object attributes

The object attribute must be placed in front of the type. For example, to place myarray in memory that is not initialized at startup:

__no_init int myarray[10];  

The #pragma object_attribute directive can also be used. The following declaration is equivalent to the previous one:

#pragma object_attribute=__no_init 
int myarray[10]; 
标题基于SpringBoot的蛋糕烘焙分享平台研究AI更换标题第1章引言介绍蛋糕烘焙分享平台的研究背景、意义、现状以及论文的方法和创新点。1.1研究背景与意义分析蛋糕烘焙行业的现状,阐述分享平台的重要性和意义。1.2国内外研究现状综述国内外在蛋糕烘焙分享平台方面的研究进展。1.3论文方法及创新点概述论文的研究方法,突出创新点。第2章相关理论介绍SpringBoot框架和分享平台开发的相关理论。2.1SpringBoot框架概述简述SpringBoot框架的特点、优势和应用场景。2.2分享平台技术基础阐述分享平台开发所需的技术基础,如前后端分离、数据库设计等。2.3用户行为分析理论介绍用户行为分析的基本理论和方法,为平台功能设计提供指导。第3章平台需求分析对蛋糕烘焙分享平台进行需求分析,明确平台功能和性能要求。3.1目标用户群体分析分析平台的目标用户群体,了解其需求和特点。3.2功能需求分析详细分析平台应具备的功能,如用户注册、烘焙教程发布、互动交流等。3.3性能需求分析对平台的性能要求进行分析,确保平台的稳定性和可扩展性。第4章平台设计根据需求分析结果,设计蛋糕烘焙分享平台的整体架构和详细功能。4.1平台架构设计设计平台的整体架构,包括前后端分离、数据库设计等。4.2功能模块设计详细设计平台的功能模块,如用户管理、内容管理、互动交流模块等。4.3数据库设计根据平台需求,设计合理的数据库表结构和数据字典。第5章平台实现与测试介绍平台的实现过程,包括环境搭建、编码实现和测试等环节。5.1环境搭建与配置搭建开发环境,配置必要的软件和工具。5.2编码实现按照设计要求,编写平台的前后端代码。5.3平台测试与优化对平台进行测试,发现并解决问题,优化平台性能。第6章结论与展望总结论文的研究成果,展望未来的研究方向和应用前景。6.1研究结论概括论文的主要研究内容和取得的成果。6.2未来研究
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值