Re: Precompiled headers on C

From: Bonj (benjtaylor)
Date: 10/17/04


Date: Sun, 17 Oct 2004 13:49:51 +0100

That's in a situation where c++ actually *would* be faster. I've got
sections of my program that are written in C++ because there's no way they
could be written in C, namely, they involve ATL. What with ATL being faster
and smaller than MFC I'm happy with that, but don't get me wrong, I can't
see how using C++ for the part of my program that manages the resource data
could actually be faster. It's pointless pointing me to *one example* of how
C++ can be faster in some particular tests, because someone else could point
me to another example of how a C version would be faster than a C++ version
in their own particular tests. It just proves that that particular piece of
code was a candidate for object oriented programming, so was faster in C++,
but it doesn't prove anything with respect to my own scenario.
In my scenario, the data is in a collection of nodes, but they are
explicitly arranged into a 'flat' format by the program that generates them,
in order that they can be arranged in one contigious block in the resource
file. To write a C++ class or even struct and to try to rearrange them into
a non-flat structure would be both time consuming for me and for the
program - as it would have all this work to do at start-up time. Not
counting the fact that it would use bags more heap memory, 400KB more to be
precise. And what's more, far from being faster to access, I can't even be
sure that it would be *as quick* to access. If this is left in global
namespace and accessed with just one pointer that traverses back and forth
through the structure as and when it needs to, there is going to be minimal
overhead.
No offence, but I really wish people would ask the question that has been
asked, rather than trying to take a step back and look at the bigger picture
and pick apart the questionner's motives and before trying to answer the
question they think should have been asked.
Example: the question that's been asked was "How do I use precompiled
headers in a project with .c files?". The question you answered was 'Mmmm...
I've got this project that's got some .c files in it.... I get a precompiled
header error when I try to compile it now. I need it to be fast but I'll go
for anything that seems to be the flavour of the month/year/decade, how
should I proceed ? "
I also don't really like people that point to a web resource not authored by
them that isn't at all relevant to the question been asked.

But I'm sure you're good at what you do and you mean well, and you are a
fellow programmer and did take the bother of answering at all, so I thank
you for that and hope you don't take offence.

"Bo Persson" <bop@gmb.dk> wrote in message
news:OGoNsyDtEHA.1452@TK2MSFTNGP11.phx.gbl...
>
> "Bonj" <benjtaylor at hotpop d0t com> skrev i meddelandet
> news:%23AKW7E9sEHA.3572@tk2msftngp13.phx.gbl...
>>
>> I personally very much doubt that there is any way of using the C++-only
>> features or the way C++ compiles that C doesn't, in order to increase the
>> speed of the program. But if this is what you meant by "using C++ as a
>> better C", then please tell me what they are - because I don't know them!
>> What I mean is, when I compile C, it is an old language that has been
>> around since the seventies or something. But the compiler I'm using
>> hasn't been around since the seventies, so the only advantages in using
>> C++ would be in what functionality I could use, not performance.
>
> Have you seen this paper by Bjarne Stroustrup, where he shows an example
> of just how much faster C++ can be ?
>
> http://www.research.att.com/~bs/new_learning.pdf
>
>
> :-)
>
>
> Bo Persson
>
>



Relevant Pages

  • Re: Precompiled headers on C
    ... see how using C++ for the part of my program that manages the resource data ... No offence, but I really wish people would ask the question that has been ... header error when I try to compile it now. ...
    (microsoft.public.vc.language)
  • Re: using PlaySound within a dll
    ... > I have a dll with a module, class and resource file. ... PlaySound has the capability to play a .wav file directly from the ... Compile your DLL. ...
    (microsoft.public.vb.winapi)
  • Re: is there a way to set the version information from the program
    ... swezeyt wrote: ... Since I have to set these #defines when I compile the program anyway ... Currently for each version I have to go in and manually change it in the resource Script by hand using the resource editor. ... I usually create a version.h header file in which I tags to represent all version-related information, such as the release version in both a string and any numeric formats required. ...
    (microsoft.public.vc.language)
  • Re: compile hta file
    ... If you google up HTA ... into a "resource" block, and then compiling that into an exe or dll. ... executables which contains stuff like text resources (which can be ... testing this article but can't get it to compile an ".hta" file. ...
    (microsoft.public.scripting.vbscript)
  • Re: Takes long duration for compilation
    ... No offence, but it's a pretty silly question. ... On my two-way SMP machine the Linux 2.4.20 kernel compiles in about a ... minute using a parallel compile. ...
    (comp.os.linux.embedded)