Connecting Tech Pros Worldwide Forums | Help | Site Map

Doubts regarding C++ runtime

Ritesh Kapoor
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi,


I have been reading some text on C and C++ (i.e advanced books). One
of the books mentioned that C++ requires a runtime support whereas C
does not - what the author was trying to say was that once you compile
a C program the executable created is all that is needed whereas if you

compile a C++ program the executable created requires a C++ runtime
installed on your system to run the program.


Can someone please provide more information on this or could provide a
link to some webiste where this concept is explained in detail. I
would like to know the differences in C and C++ compiled code which
makes a runtime necessary for one and not for the other.

I had posted this on the comp.lang.c group but found that this topic
doesn't fit into that group, so trying my luck here.

Thanks
Ritesh




Alf P. Steinbach
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Doubts regarding C++ runtime


* Ritesh Kapoor:[color=blue]
> I have been reading some text on C and C++ (i.e advanced books). One
> of the books mentioned that C++ requires a runtime support whereas C
> does not[/color]

A formally correct program requires runtime support in both languages.

For example, globals are (usually) initialized before 'main' is executed.

Usually that support is statically linked. Whether it is depends on the
implementation and what you direct it to do. Both languages also have
implementations where you can choose to not use the runtime support.

[color=blue]
> - what the author was trying to say was that once you compile
> a C program the executable created is all that is needed whereas if you
> compile a C++ program the executable created requires a C++ runtime
> installed on your system to run the program.[/color]

No.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Karl Heinz Buchegger
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Doubts regarding C++ runtime


Ritesh Kapoor wrote:[color=blue]
>
> Hi,
>
> I have been reading some text on C and C++ (i.e advanced books). One
> of the books mentioned that C++ requires a runtime support whereas C
> does not - what the author was trying to say was that once you compile
> a C program the executable created is all that is needed whereas if you
>
> compile a C++ program the executable created requires a C++ runtime
> installed on your system to run the program.[/color]

Ahm, no.
The author is right, that C++ needs more runtime support (because eg. there
is much more going to happen during program startup). But he is not right
in saying that this runtime needs to be *installed* on a system. All
development systems I am aware of provide 2 options: Either you can ship
the runtime in the form of a 'shared library' or you can link the runtime
into the final executable. This is true for C *and* C++. So it is only
the programmer itself that makes the decission if he wants to ship 1
executable and get rid of the problem of having some to ship some libraries
in the correct version with his product or to ship just one single executable
and don't have that problem.


--
Karl Heinz Buchegger
kbuchegg@gascad.at
Closed Thread