Jump to content
  • Advertisement
Sign in to follow this  
widggman

__unused__

This topic is 3710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! In C++, what "__attribute__ ((__unused__))" do ? In which context I would like to use that ? What's the difference between: int x __attribute__ ((__unused__)) = 3; and: int x = 3; Thanx!

Share this post


Link to post
Share on other sites
Advertisement
__attribute__ ((__unused__)) is probably a macro that expands to nothing. Try using g++ with the -E switch, and you'll see.

Share this post


Link to post
Share on other sites
It is a variable attribute. You can find many more of these in the docs.

The difference for this particular attribute is that you explicitely tell the compiler "I might not use this variable", so when compiling with warnings enabled, it will not emit a warning if that happens. You won't normally need this attribute.
Note that if you initialize a variable (int x = 3;), you are using it, so in that case the compiler wouldn't warn anyway, and the attribute has no effect.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!