What is the IAR equivalent of '__attribute__ ((weak, alias (#f))) '?

狂风中的少年 提交于 2020-02-23 07:38:05

问题


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:

In the past (GNU):

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

What is different if the compiler change to IAR?

If I use the same syntax I get the error:

Error[Pe130]: expected a "{"

Any suggestion would be appreciated!


回答1:


You should be able to use #pragma weak CSV_IRQHandler=IntDefaultHandler

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.


来源:https://stackoverflow.com/questions/25619377/what-is-the-iar-equivalent-of-attribute-weak-alias-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!