Re: #pragma once in ISO standard yet?
On Dec 15, 6:16 pm, Andre Kaufmann <akfmn...@t-online.de> wrote:
Bo Persson wrote:
Andre Kaufmann wrote:
[...]
And if it doesn't work, how are you as a programmer going to fix that?
1) Change the environment
2) Use both - #pragma comment and include guards
3) The programmer is not responsible for the infrastructure
that's the task of the it administrator
4) But there are always other solutions - see below
As a somewhat nasty example, I have a PC at work, which I
cannot configure myself, with
local hard disk
several (non-unique) mounts to Windows servers (group and
departmental)
several SAN mounts
access to a ClearCase mount on a UNIX server
one drive letter mapping to files on a zOS mainframe
Copy the sources and directory structure to your local PC and
compile them from there ?
I'd rather use an intelligent version control system, rather
than have to be sure of updating manually at the correct moment.
Remember that intelligent version control systems, like
Clearcase, behave as file servers, so that you always see the
version you're supposed to see.
For that matter, I don't think I've ever worked at a place where
the source files were on a local disk. What do you do when you
start discussing them with a collegue, on his machine?
Anyways better to compile on a local machine than compiling
over network, or am I totally wrong ?
Totally wrong. Complete builds would take forever on a single
machine. Your local remakes, of course, will all be compiled on
your machine, but the only way to be sure that you've got the
right versions of all of the headers is to go through some sort
of central server.
Must any nasty hardware construction/topology be supported or
should the hardware infrastructure be adopted to the compiler?
No. That's exactly why `#pragma once' doesn't work: it would
require some nasty topology to work, rather than using something
sensible.
How should the C++ standard specify #pragma once, so that it
always works? Or should it be unportable?
You can always choose to additionally use include guards -
can't you?
What's the point in having #pragma once, if you also need
include guards.
And C++ can't be (fully) ported to every platform. If you
restrict the compiler always to the lowest common platform you
will effectively restrict the language itself.
But anyways there is a always 100% portable solution, besides
using additionally include guards, though it doesn't offer the
normal speed gain of #pragma once.
#pragma once doesn't offer any speed gain. There is absolutely
no difference in build times with g++ when you use include
guards instead of #pragma once. Including over a slow network.
If the compiler calculates a hash value of the content of a
header file it can compare it always with the content of
another header file. This solution could be used in non
portable scenarios or when the compiler can't detect the files
to be identical or if it can't add meta information to the
code files itself.
There are 100 solutions, I know it's not that simple as it
seems to be - but IMHO there's no reason to drop such features
like #pragma once.
The experience of the people at gcc seems to indicate the
opposite.
All in all, header files are causing too much troubles. So
it's best to get rid of them as soon as possible. They aren't
worth the trouble.
I'm all for getting rid of header files completely. As soon as
we get a replacement for them which works.
--
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 ]