Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

boywunder

#pragma once

This topic is 5755 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

I was over looking some code a few days ago and this was at the top of the file. I reconized it as a valid syntax, but I haven''t ever seen it used. I flipped through two of my c++ books and failed to find what it is. Can anybody enlighten me?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
MSVC specific extension for header guards ie

#ifndef FOO_H_
#define FOO_H_
//header content here
#endif

=>

#pragma once
//header content here

Share this post


Link to post
Share on other sites
It essentially does the same as:
In MyFile.h:

#ifndef MY_FILE_H_INCLUDED
#define MY_FILE_H_INCLUDED
// .h file stuff
#endif

Share this post


Link to post
Share on other sites
I would have thought you could find documentation on the pragma preprocessor directive.

If you use pragmas they are implementation dependant meaning your code won''t necessarily be portable. They will be ignored by compilers that don''t recognise them.

Share this post


Link to post
Share on other sites
from MSDN

quote:
Specifies that the file will be included (opened) only once by the compiler in a build. This can reduce build times as the compiler will not open and read the file after the first #include of the module.




:::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile

Share this post


Link to post
Share on other sites

  • 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!