Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » [[gnu::unused]] is marked as incorrect syntax.
[[gnu::unused]] is marked as incorrect syntax. [message #1750723] Tue, 27 December 2016 12:12 Go to next message
Stephen Lynx is currently offline Stephen LynxFriend
Messages: 1
Registered: December 2016
Junior Member
I have eclipse playing ball with C++11, but I can't make it accept [[gnu::unused]], it just says its invalid syntax. Any idea on how to make it see it as valid?
Re: [[gnu::unused]] is marked as incorrect syntax. [message #1750875 is a reply to message #1750723] Fri, 30 December 2016 14:27 Go to previous message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
It's a gnu extension. The only attributes you should use are the standard ones listed here: http://en.cppreference.com/w/cpp/language/attributes
Also read: http://stackoverflow.com/questions/31909631/c11-style-unused-attribute-in-gcc

The closest standard attribute is probably [[maybe_unused]] and is only defined in C++17.
Either ignore the warning or use a pragma or command line option to turn it off,

You might also get away with defining a macro ATTR(x) that gives CODAN an empty string and the compiler what it needs:

#ifdef __CDT_PARSER__
#define ATTR(x) 
#else
#define ATTR(x) [[x]]
#endif

Personally, I don't see the utility in defining something that isn't used. YMMV


Previous Topic:Getting chosen project type from an MBS custom page
Next Topic:Error launching openOCD debugger in Eclipse
Goto Forum:
  


Current Time: Thu May 26 20:43:05 GMT 2022

Powered by FUDForum. Page generated in 0.01940 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top