Eclipse CDT syntax error on __attribute__ keyword

南笙酒味 提交于 2019-12-04 18:44:51

The "ECLIPSE_THINKS_THIS_IS_SET_BUT_GCC_DOESNT" definition (from ams's answer) really extsts and it called __CDT_PARSER__. For example:

#ifdef __CDT_PARSER__
#define __FILE__                "<file>"
#define __LINE__                (-1)
#define __DATE__                "<date>"
#define __TIME__                "<time>"
#endif // #ifdef __CDT_PARSER__

Hope this will be helpful.

I've not tried it, and I've not used Eclipse for some time, but here's an idea:

In the CDT settings for Eclipse (or maybe just your project) set up a predefined macro (I seem to remember you can tell it what the compiler auto-defines) named __attribute__ that takes one parameter, and expands to nothing.

Maybe I haven't explained that right. Let me try again with an example. Basically, the aim is to define a macro that works like this:

#if ECLIPSE_THINKS_THIS_IS_SET_BUT_GCC_DOESNT
#define __attribute__(X) /* nothing */
#endif

but without putting anything actually in your code.

ziu
Project->Properties->C/C++ general->Path and Symbols->Symbols

Add-> 
     Name: __attribute__(X)
     Value: (leave blank)

Related links: You can use this technique basically with any offending keyword

ziu's answer is also working for XC8 Microchip compilers

Name: __interrupt
Value: (leave blank)

The function prototype now is clean:

void __interrupt ISRs(void);

And Eclipse won't complain about it.

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