top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

GNU attributes with C++11 syntax?

+2 votes
125 views

GCC gives a warning for this program:

int main()
{
    int x;
}

test.cpp: In function 'int main()':
test.cpp:3:9: warning: unused variable 'x' [-Wunused-variable]

If I add an "unused" attribute with the GNU syntax:

int x __attribute__((unused));

the warning goes away.

However, if I use the C++11 syntax:

int x [[unused]];

the warning remains, and I also get:

test.cpp:3:20: warning: 'unused' attribute directive ignored [-Wattributes]

Does anyone know about gcc plans to support the attributes with C++11 syntax.

posted May 4, 2014 by Dewang Chaudhary

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Try [[gnu::unused]].

Similar Questions
0 votes

how can I configure GCC to emit the calls to __cxa_thread_atexit() for destructor registration? On a Linux PowerPC target I see the registration of destructors, but not on the powerpc-rtems target. I guess I missed a configuration option or define. Has someone a hint for me?

+1 vote
struct xx
{
 int x;
 struct yy *p;
 struct
 {
 int s;
 };
 struct
 {
 int s;
 };    
};

int main()
{    
 struct xx xyz;
 printf("%d",sizeof(xyz));
 return 0;
}

the above code compile well without any warning. Here my question is
1. How can I distinguish two 's' variable.
2. What is use case.

0 votes

Is "cpp -P" POSIX? I poked around at

http://www.opengroup.org/onlinepubs/9699919799

and could find only matches to "preprocessor" rather than "cpp" in the search facility, and so surmise "no", but thought i'd ask here anyway. I suppose a portable workaround would be:

cpp FILENAME | sed '/^#/d'

but have fingers crossed nonetheless...

0 votes

I'm studying about C compiler for increasing software quality. So I want to get all of compile error message list of gcc about C language. I was trying to find it. But I can't find it anywhere. How can I find it?

Please help?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...