Doubts regarding C++ runtime

R

Ritesh Kapoor

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
 
A

Alf P. Steinbach

* Ritesh Kapoor:
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

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.

- 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.

No.
 
K

Karl Heinz Buchegger

Ritesh said:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top