473,804 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is #pragma once used for

What is #pragma once used for
and
what is #WIN#@_LEN_AND_ MEAN
Mar 27 '08 #1
5 25226
On 27 Mrz., 06:12, raashid bhatt <raashidbh...@g mail.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_ME AN preprocessor symbol in MS
Visual C++ excludes rarely used stuff from the platform specific
#include files (windows.h, ...).

best,

Michael
Mar 27 '08 #2
On Mar 27, 6:12 am, raashid bhatt <raashidbh...@g mail.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 objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Mar 27 '08 #3
On 27 maalis, 11:36, James Kanze <james.ka...@gm ail.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
On Mar 27, 11:34 am, Krice <pau...@mbnet.f iwrote:
On 27 maalis, 11:36, James Kanze <james.ka...@gm ail.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 objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Mar 27 '08 #5
Mi************* **@gmail.com wrote:
On 27 Mrz., 06:12, raashid bhatt <raashidbh...@g mail.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
8592
by: Jacob Jensen | last post by:
Hi I have a problem creating C++ code that is multiplatform compilable. My problem is using the "#pragma once" directive which can be used by microsoft Visual Studio pre-compiler but which gives warnings when used by gcc for example. I would like to use it when compiling with Visual C++ compiler, but how can I create a smart macro or something, so that it is truly ignored when compiler with gcc. I have tried the following which actually...
187
6561
by: Lasse Espeholt | last post by:
Hi... I am relativ new to the impressive and powerfull C language, but i thinks it is obsolete... The idea with header/source files where methods can clash into eachother i don't like... Look at C# which is much cleaner with namespaces. Why has C not namespaces and a "area idea" where some methods and
7
15361
by: Studlyami | last post by:
Okay I have been wondering this for a while now. I am a little confused on the difference between these two defines #pragma once & #ifndef. From my understanding #pragma is compiler dependent, meaning that it will be handled differently depending on the compiler? #ifndef is not dependent on the compiler. So from that i take it that its more universal to use #ifndef because its the standard, but if I use #pragma once in visual...
26
3832
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? Thanks...
3
3902
by: Subrat | last post by:
Hello, I have used #pragma once in a header file. During compilation I get a warning : #pragma once is obsolete. How do I switch off this warning, without making any change to my make file? Thanks in Advance, Subrat
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9587
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.