#pragma once
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?
MSVC specific extension for header guards ie
#ifndef FOO_H_
#define FOO_H_
//header content here
#endif
=>
#pragma once
//header content here
#ifndef FOO_H_
#define FOO_H_
//header content here
#endif
=>
#pragma once
//header content here
It essentially does the same as:
In MyFile.h:
In MyFile.h:
#ifndef MY_FILE_H_INCLUDED#define MY_FILE_H_INCLUDED// .h file stuff#endif
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.
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.
from MSDN
:::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement