[Gllug] Office software -> c/c++ debate

Stig Brautaset stigbrau at start.no
Sat Nov 17 23:31:12 UTC 2001


* Pete Ryland <pdr at pdr.cx> spake thus:
> On Sat, Nov 17, 2001 at 04:43:57PM +0000, Bruce Richardson wrote:
> > On Fri, Nov 16, 2001 at 03:26:42PM +0000, Pete Ryland wrote:
> > > C++ is a superset of C.
> > 
> > Some C code is not valid C++, so that is not strictly accurate.
> > Objective-C was specifically designed to be a superset of C and so to
> > compile all C code.  It's supporters also cite the simpler O-O model as
> > an advantage.
> 
> oh ok, I always saw it as strictly a superset.  [off topic?] What sort of
> stuff is not downward compatible?

This is a faq:

20.27:  Is C++ a superset of C?  Can I use a C++ compiler to compile C
        code?

A:      C++ was derived from C, and is largely based on it, but there
	are some legal C constructs which are not legal C++.
	Conversely, ANSI C inherited several features from C++,
	including prototypes and const, so neither language is really a
	subset or superset of the other; the two also define the meaning
	of some common constructs differently.  In spite of the
	differences, many C programs will compile correctly in a C++
	environment, and many recent compilers offer both C and C++
	compilation modes.  See also questions 8.9 and 20.20.

	References: H&S p.  xviii, Sec.  1.1.5 p.  6, Sec.  2.8 pp.
	36-7, Sec.  4.9 pp.  104-107.

As a test, try compiling something like the below with a C++ compiler:

char *new, *delete;
new = malloc(sizeof new);
delete = malloc(sizeof delete);
free(new);
free(delete);

(It is a bit of a low blow, I admit that; still I don't think it is an
unreasonable assumption that people programming in C use `new' and
`delete' as variable names.)

Regards,
Stig

-- 
brautaset.org
Registered Linux User 107343

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list