#pragma once
-
I'm confused. If you have a header named "myheader.h" defined has:
/*-----------------
myheader.h
-----------------*/
#ifndef MyHeaderH
#define MyHeaderH
//-------------------------------
// Everything else goes here
//-------------------------------
#endif // MyHeaderThen what's the use of the "#pragma once" directive if both are used to include a file only once? Or am I wrong and they have different purposes? I've seen the "#pragma once" definition here Thanks in advance hint_54
-
I'm confused. If you have a header named "myheader.h" defined has:
/*-----------------
myheader.h
-----------------*/
#ifndef MyHeaderH
#define MyHeaderH
//-------------------------------
// Everything else goes here
//-------------------------------
#endif // MyHeaderThen what's the use of the "#pragma once" directive if both are used to include a file only once? Or am I wrong and they have different purposes? I've seen the "#pragma once" definition here Thanks in advance hint_54
Well AFAIK both accomplishes the same purpose. Apart from that(AFAIK)
#pragma
maintains a list of included files too.
Nibu thomas Software Developer
-
Well AFAIK both accomplishes the same purpose. Apart from that(AFAIK)
#pragma
maintains a list of included files too.
Nibu thomas Software Developer
-
I'm confused. If you have a header named "myheader.h" defined has:
/*-----------------
myheader.h
-----------------*/
#ifndef MyHeaderH
#define MyHeaderH
//-------------------------------
// Everything else goes here
//-------------------------------
#endif // MyHeaderThen what's the use of the "#pragma once" directive if both are used to include a file only once? Or am I wrong and they have different purposes? I've seen the "#pragma once" definition here Thanks in advance hint_54
from cplusplus.com[^] The pragma directive is used to specify diverse options to the compiler. These options are specific for the platform and the compiler you use. Consult the manual or the reference of your compiler for more information on the possible parameters that you can define with #pragma. If the compiler does not support a specific argument for #pragma, it is ignored - no error is generated.
#pragma once
is supported by many but not all compilers. If you want to write code that works with a number of compilers, you should use the old fasioned #define... method. Regards, Dan Remember kids, we're trained professionals.
Don't try this at home! -
Then if I use only one of them its the same thing, right? regards PS: what does AFAIK mean?? hint_54
hint_54 wrote:
Then if I use only one of them its the same thing, right?
Dan has answered your query. :)
hint_54 wrote:
PS: what does AFAIK mean??
As Far As I Know.:-D
Nibu thomas Software Developer