本文介绍了IAR与'__attribute__((weak,alias(#f)))'的等效含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时使用LPC系列(NXP)作为控件.现在,我们要切换到另一个MCU(Spansion),编译器是从GNU到IAR. IAR和GNU之间的某些属性不同,我想寻求帮助:

I was using LPC series (NXP) as control something. And now, we are switching over to another MCU (Spansion) and the compiler is from GNU to IAR. Some attribute doesn't the same between IAR and GNU, I would like to ask for help:

过去(GNU):

#define ALIAS(f) __attribute__((weak, alias (#f)));
#define CSV_IRQHandler(void)   ALIAS(IntDefaultHandler)

如果编译器更改为IAR,有什么不同?

What is different if the compiler change to IAR?

如果我使用相同的语法,则会收到错误消息:

If I use the same syntax I get the error:

Error[Pe130]: expected a "{"

任何建议将不胜感激!

推荐答案

您应该可以使用#pragma weak CSV_IRQHandler=IntDefaultHandler

摘自《 IAR C/C ++开发指南》

From the "IAR C/C++ Development Guide"

weak

Syntax           #pragma weak symbol1={symbol2}

Parameters       symbol1 A function or variable with external linkage
                 symbol2 A defined function or variable.

Description      This pragma directive can be used in one of two ways:
                 ● To make the definition of a function or variable with external linkage a weak
                   definition. The __weak attribute can also be used for this purpose.
                 ● To create a weak alias for another function or variable. You can make more
                   than one alias for the same function or variable.

 Example        To make the definition of foo a weak definition, write:

                #pragma weak foo

                To make NMI_Handler a weak alias for Default_Handler, write:

                #pragma weak NMI_Handler=Default_Handler

                If NMI_Handler is not defined elsewhere in the program, all references to
                NMI_Handler will refer to Default_Handler.

这篇关于IAR与'__attribute__((weak,alias(#f)))'的等效含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 22:41