I would like to know if there is a way to get rid of CDT syntax error warnings when using gcc's "__attribute__
" keyword.
It goes without saying that I would not like to switch off CDT syntax check.
I would like to know if there is a way to get rid of CDT syntax error warnings when using gcc's "__attribute__
" keyword.
It goes without saying that I would not like to switch off CDT syntax check.
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:
but without putting anything actually in your code.
Related links: You can use this technique basically with any offending keyword
The "ECLIPSE_THINKS_THIS_IS_SET_BUT_GCC_DOESNT" definition (from ams's answer) really extsts and it called
__CDT_PARSER__
. For example:Hope this will be helpful.
ziu's answer is also working for XC8 Microchip compilers
The function prototype now is clean:
And Eclipse won't complain about it.