Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Apr 2006 23:10:40 +0200
From:      des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?=)
To:        Don Dugger <dugger@hotlz.com>
Cc:        freebsd-chat@freebsd.org
Subject:   Re: Why is not more FreeBSD software written in C++?
Message-ID:  <86mzednwof.fsf@xps.des.no>
In-Reply-To: <444A8106.5010801@hotlz.com> (Don Dugger's message of "Sat, 22 Apr 2006 12:16:22 -0700")
References:  <44490663.3040506@hotlz.com> <86d5f9pno8.fsf@xps.des.no> <444A6B54.1030902@hotlz.com> <86vet1o5j3.fsf@xps.des.no> <444A8106.5010801@hotlz.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Don Dugger <dugger@hotlz.com> writes:
> Dag-Erling Sm=F8rgrav <des@des.no> writes:
> > Don Dugger <dugger@hotlz.com> writes:
> > > Dag-Erling Sm=F8rgrav <des@des.no> writes:
> > > > Don Dugger <dugger@hotlz.com> writes:
> > > > > The fact is that all your c code will compile in c++
> > > > That is wrong.  To name just one example, C++ is much stricter about
> > > > type casts than C is.
> > > I mean the constructs. Casting will not change the functionality or
> > > shouldn't.
> > It does.  Casting can be (and often is) used to force or avoid sign
> > promotion in function arguments; for instance, isspace(ch) may produce
> > incorrect results if ch is a char, so a cast to int is required.
> >
> > C allows any expression of pointer type to be assigned to a void *,
> > and allows any expression of type void * to be assigned to any object
> > pointer type.  C++ does not.  As a result, a typical C program which
> > uses malloc() without casting the result will not compile cleanly with
> > a C++ compiler.  A competent C programmer will balk at adding the cast
> > that C++ requires; a competent C++ programmer will correctly point out
> > that a C++ program should not use malloc() anyway.
> >
> > There are other incompatiblities: const has different semantics in C
> > and C++, namespaces aren't quite the same (there is no separation
> > between the typedef namespace and the struct namespace in C++), etc.
> And how does that change my point?

You claim (on the first line quoted above) that "all your c code will
compile in c++".  I am trying to show that you are wrong.

DES
--=20
Dag-Erling Sm=F8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86mzednwof.fsf>