The table below compared the details of pragma once and #ifndef #define #endif approach:
pragma once | #ifndef #define #endif | |
Sample code | // header file #pragma once class foo { }; | // header file #ifndef FOO_HEADER #define FOO_HEADER class foo { }; #endif // FOO_HEADER |
C++ Standard | No But both GCC and Microsoft Visual C++ support it. | Yes |
Compiling Performance | Better This can reduce build times as the compiler will not open and read the file after the first #include of the module. | It will still have to open the file multiple times, and discard the guard part when compiler find the macro guard. In a large project this could cause increased compile times. But you can also optimize the compiling performance of #ifdef #define #endif approach by this way. |
Clear explaination and understood.
ReplyDeleteAny idea whether the pragma statment will be included in the new C++ standard (C++0x)?
ReplyDeletehttp://bantalsilikon01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
ReplyDeletehttp://marinirseo.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
http://kopiluwakliar01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
http://bumbupecel1.blogspot.com/2014/10/bantalsilikon01blogspotcom.html
http://bantalsilikon01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
http://marinirseo.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
http://kopiluwakliar01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
http://bumbupecel1.blogspot.com/2014/10/bantalsilikon01blogspotcom.html
a
http://marinirseo.blogspot.com
http://kopiluwakliar01.blogspot.com
http://bumbupecel1.blogspot.com
http://bantalsilikon01.blogspot.com
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb