By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,899 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,899 IT Pros & Developers. It's quick & easy.

What is #pragma once used for

P: n/a
What is #pragma once used for
and
what is #WIN#@_LEN_AND_MEAN
Mar 27 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 27 Mrz., 06:12, raashid bhatt <raashidbh...@gmail.comwrote:
What is #pragma once used for
and
what is #WIN#@_LEN_AND_MEAN
#pragma once directs the preprocessor of MS Visual C++ to #include the
file only one time per compilation unit, even if more than one
#include for the file is encountered. #pragma is the standard way to
add non-standard behavior to C++; other compilers will just ignore the
line. A better way to achieve the effect would be

xyz.h:

#ifndef _XYZ_H_INCLUDED
#define _XYZ_H_INCLUDED
.... /* remainder of file */
#endif

The definition of the WIN_LEAN_AND_MEAN preprocessor symbol in MS
Visual C++ excludes rarely used stuff from the platform specific
#include files (windows.h, ...).

best,

Michael
Mar 27 '08 #2

P: n/a
On Mar 27, 6:12 am, raashid bhatt <raashidbh...@gmail.comwrote:
What is #pragma once used for
Making code non-portable.
and
what is #WIN#@_LEN_AND_MEAN
Locking you 100% into a specific compiler vendor.

I've never used either in my code, and don't expect I ever will.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Mar 27 '08 #3

P: n/a
On 27 maalis, 11:36, James Kanze <james.ka...@gmail.comwrote:
Locking you 100% into a specific compiler vendor.
I guess other compilers also have compiler specific stuff,
like __attribute() in gcc, which doesn't work in VC++ and
is not a part of C++ standard.
Mar 27 '08 #4

P: n/a
On Mar 27, 11:34 am, Krice <pau...@mbnet.fiwrote:
On 27 maalis, 11:36, James Kanze <james.ka...@gmail.comwrote:
Locking you 100% into a specific compiler vendor.
I guess other compilers also have compiler specific stuff,
like __attribute() in gcc, which doesn't work in VC++ and
is not a part of C++ standard.
And which, of course, I don't use either. (To be fair to
Microsoft: the very name used screamed Windows. It's hard to
pretend that you didn't at least suspect that it wasn't 100%
portable.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Mar 27 '08 #5

P: n/a
Mi***************@gmail.com wrote:
On 27 Mrz., 06:12, raashid bhatt <raashidbh...@gmail.comwrote:
>What is #pragma once used for
and
what is #WIN#@_LEN_AND_MEAN

#pragma once directs the preprocessor of MS Visual C++ to #include the
file only one time per compilation unit, even if more than one
#include for the file is encountered. #pragma is the standard way to
add non-standard behavior to C++; other compilers will just ignore the
line. A better way to achieve the effect would be

xyz.h:

#ifndef _XYZ_H_INCLUDED
#define _XYZ_H_INCLUDED
... /* remainder of file */
#endif
<snip>

We actually put BOTH #pragma once and the #ifndef syntax into our header
files.

#pragma once compiles faster; once the compiler has seen it for a .h
file, it doesn't even open the file the 2nd time, whereas the other,
portable, syntax requires the compiler to read the entire file again.
Even though it only requires very light processing it still takes some time.

But this is strictly MS only.

#WIN#@_LEN_AND_MEAN? Never seen it. It sound a bit like the

#define WIN32_LEAN_AND_MEAN that MS use to minimise bloat (as
Christopher put it)

See http://support.microsoft.com/kb/166474

Andy
Mar 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.