Re: #pragma once in ISO standard yet?
On Dec 16, 1:52 am, akfmn...@t-online.de (Andre Kaufmann) wrote:
Pete Becker wrote:
[...]
GCC not only implements it, but declares that it's obsolete!
As has been said before in this thread, the problem with
#pragma once is that the compiler has to get it right, but
doesn't have enough information to do that. That's a classic
case for not putting it in the language, and leaving it to
programmers to ensure that what they're doing works right.
And that's a classic example, how it shouldn't be. It's all up
to the programmer to get it right ?
Given that the compiler can't. And it's the programmer, or
other tools. It's been years since I've written an include
guard myself.
Which other language requests the programmer to do it right,
regarding header files ? Are all the others doing something
wrong ?
As far as I know, all other languages require the programmer to
do the right thing. For different definitions of the right
thing. (Well, Java forbids the programmer to do the right
thing, since the right thing does require keeping the
implementation and the interface specification in two different
files. But from what I understand, Java programmers have come
up with work-arounds for this defect.)
Dealing with header files costs a lot of time and energy. The
compiler has to compile each header file again and again and
again, every time it's used. Why ? It's mainly the same code,
besides let's say by abusing macros. The same project using
precompiled header files compiles way more faster, than the
same not using them. Modules are already proposed, but
unfortunately are not part of the new standard. Pragma once
helps somewhat, so that the compiler doesn't has to load and
parse the header file again.
As mentionned before: compiling with #pragma once, or with
include guards, makes absolutely no difference in build times,
at least with g++. And that despite having to read the files
over an overloaded network, from a somewhat flakey fileserver
which sometimes takes its time responding.
Whatever arguments there might be, build times is not one.
And it's the task of the OS to check if 2 paths point to the
same file. Either by marking it with a hash code or by
normalizing the path.
None of the OS's I know can do this. There's no support for it
in either NFS nor SMB, so practically, it isn't implementable if
the files are mounted using one of those protocols.
--
James Kanze (GABI Software) email:james.kanze@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
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]