Re: if !defined and #pragma once

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Apr 1, 3:24 pm, David Wilkinson <no-re...@xxxxxxxxxxxx> wrote:
Ajay Kalra wrote:
On Apr 1, 6:18 am, asm23 <asmwarr...@xxxxxxxxx> wrote:
Hi,I'm a visual c++ 6.0 user. I'm confused that the CPP file generated
by the IDE always have these statement below:

#if!defined(AFX_XXXXX_H__32583F3A_E701_4274_AFD6_426BC1C59E81__INCLUDED_)
#define AFX_XXXXX_H__32583F3A_E701_4274_AFD6_426BC1C59E81__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

So, my question is "#if! defined (XXXX...)" is really useless? as the
newer compiler such as VS.NET 2001 VC.NET 2003...2008 all support the
#pragma once. the "if! ..." is functionally redundant.Is it right? Thanks.

Just use #pragma once instead. Since this pragma was added in VC6,
anything before that will not recognize. So for code for VC5 etc, this
was kept in VC6. It no longer is an issue and I only use #pragma once.

Ajay:

VC5 was _MSC_VER = 1100. "#pragma once" was in the wizard code in VC5.


Thanks. Is it correct that it was introduced in VC5 then?

---
Ajay

.



Relevant Pages

  • Re: Routines in mixed (managed and native) assemblies
    ... I was a bit confused with the "#pragma managed/unmanaged". ... templates and compiler generated functions. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Question on initialization of packages
    ... and on other implementations (which don't support it), ... can be used with any compiler. ... Saying "we have a pragma X" implies that it's part of the standard. ... "GNAT has a compiler-specific pragma X" is a better way to phrase it. ...
    (comp.lang.ada)
  • Re: Preprocessor Directives
    ... Is there a preprocessor directive that will cause the compiler to ... Your best bet, and it is not a good bet, is a #pragma, if your compiler ... happens to support one that does what you want. ...
    (comp.lang.c)
  • Re: if !defined and #pragma once
    ... VC5 had such a bad reputation that I used it only briefly. ... I believe the #pragma once was ... critical information like this is NOT documented in the MSDN? ... that tells us EXACTLY what each compiler version and its release date is? ...
    (microsoft.public.vc.mfc)
  • Re: if !defined and #pragma once
    ... #pragma once ... newer compiler such as VS.NET 2001 VC.NET 2003...2008 all support the ... introduced in VC6. ... I hardly used VC5. ...
    (microsoft.public.vc.mfc)