POV-Ray : Newsgroups : povray.off-topic : Unix shell : Re: Unix shell Server Time
3 Sep 2024 17:14:44 EDT (-0400)
  Re: Unix shell  
From: Warp
Date: 2 Feb 2011 13:49:22
Message: <4d49a731@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> >   Let's take a better example: Every time I want to use std::vector,
> > I have to #include <vector> in the source file where I want to do so.

> Or, to phrase it differently:

> vector.hpp is a standard file from the standard library. Why the hell are 
> you compiling it, over and over, every time you compile your program?

  The advantage is that the end result is much more efficient (both
speedwise and memorywise) because it allows the compiler to perform
heavy-duty optimizations on the included code based on the types you are
using as well as many other things. (Of course that's not the *original*
reason to have include files, but it's a nice side-effect of them that
makes them actually quite useful.)

  (Curiously, the next C++ standard will include a feature called "extern
template" which allows you to defer the compiling of the templated code
into one single compilation unit. This doesn't have efficiency advantages,
but it can speed up compilation and make object files smaller. It's still
not the same thing as an "export template" though, and shouldn't be confused
with it.)

> Doesn't it strike you as a bit odd that standard libraries that come with 
> the compiler still get compiled on your CPU over and over?

  Not for templated code, no. As for non-templated code, they usually come
in precompiled dynamically loadable versions (or statically linkable, if
you want).

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.