什么是IAR相当于'__attribute __((弱,别名(#f)))'?

时间:2014-09-02 08:48:42

标签: gnu iar

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

过去(GNU):

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

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

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

Error[Pe130]: expected a "{"

任何建议都将不胜感激!

1 个答案:

答案 0 :(得分:1)

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

来自" IAR C / C ++开发指南"

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.