[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

#if _MSC_VER > 1000

Posted on 2001-09-07
7
Medium Priority
?
3,556 Views
Last Modified: 2013-11-20
what exactly is this statement used for
#if _MSC_VER > 1000
#pragma once
#endif
0
Comment
Question by:mjh2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6464814
This statement is used to differentiate between different compiler versions. From the docs:

_MSC_VER

Defines the compiler version. Defined as 1200 for Microsoft Visual C++ 6.0. Always defined.


This means - in your example - that the code enclosed will only be 'seen' by MS compilers that have an internal version stamp > 1000, as '#pragma once' is probably not implemented by earlier versions. 'once' itself means:

#pragma once

Specifies that the file, in which the pragma resides, will be included (opened) only once by the compiler in a build. A common use for this pragma is the following:

//header.h
#pragma once
// Your C or C++ code would follow:



0
 
LVL 49

Accepted Solution

by:
DanRollins earned 900 total points
ID: 6465898
I might add that

   #pragma once

can be used as a replacement for the common practice of placing #ifdef like this at the top and bottom of a header file:

#if !defined(DLGPGSVRPARSING_H)
#define DLGPGSVRPARSING_H
... entire source file here ...
#endif

Therefore, if you expect to always use VC++ 6.0 or later, you could manually replace this ugly baggage at the top of your .h files:
---==-=--==--=-=-=-=-=-==--=-=
#if !defined(AFX_DLGPGSVRPARSING_H__B25B9214_2E48_46EB_A306_F750626C5256__INCLUDED_)
#define AFX_DLGPGSVRPARSING_H__B25B9214_2E48_46EB_A306_F750626C5256__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
---==-=--==--=-=-=-=-=-==--=-=
with this one, clean line:

#pragma once

Just remember to also delete the #endif line tha tlooks like this from the bottom of the file:
---==-=--==--=-=-=-=-=-==--=-=
#endif // !defined(AFX_DLGPGSVRPARSING_H__B25B9214_2E48_46EB_A306_F750626C5256__INCLUDED_)
---==-=--==--=-=-=-=-=-==--=-=

-- Dan
0
 
LVL 86

Expert Comment

by:jkr
ID: 6466004
>>I might add that '#pragma once'can be used as a
>>replacement for the common practice of placing #ifdef
>>like this at the top and bottom of a header file..

You're right, but I would not recommend abandoning that practise - there are more compilers out than just VC++, even though MFC is focused a little on that compiler implementation (even though I remember that my first encounter with MFC was with Watcom 10.0)

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 86

Expert Comment

by:jkr
ID: 6468695
???
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6469592
hi mjh2,
Thanks for accepting my comment as an answer.  However, in this case, all I did was add a note to an already correct and complete answer that had been given by jkr.

The 'B' grade that you awarded to me, should instead be awarded to jkr.

hi jkr,
sorry.  I had no intention of 'poaching'.

-- Dan
0
 
LVL 86

Expert Comment

by:jkr
ID: 6472005
>>I had no intention of 'poaching'

I know - you wrote 'I might add that...'. Well, let's see what mjh22 has to say...
0
 

Author Comment

by:mjh2
ID: 6477437
I am sorry jkr.. DanRollins answer gave me more insight on what the code is used for. You gave the definition that anyone can find on Microsoft's web page.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question