🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Stephen J. Muir Thu, 14 Aug 1986 00:41
C++ on existing C programs.
#282
Author: Stephen J. Muir
Date: Thu, 14 Aug 1986 00:41
40 lines
1772 bytes
C++ is supposed to be upwards compatible with C.  Can anybody, therefore,
explain why the following does not compile (under 4.2):

# include <sys/param.h>
# include <sys/time.h>
# include <sys/file.h>
# include <stdio.h>
# include <strings.h>
# include <grp.h>

extern char	*getlogin ();

char	*basename, *cp, **cpp,
	*holidays = "/usr/games/lib/holidays",	/* format is dd/mm/yy */
	holbuf [10], realgame [100] = "/usr/games/bin/",
	*sorry [] =
	{ "Games may not be played on working days between 09:00 and 17:00.\n",
	  0
	},
	*scorers [] =	/* games which use "-s" to print scores */
	{ "rogue",
	  "robots",
	  "hack",
	  "rogomatic",
	  0
	};

int	fd = -1, wizard, group, ngroups = NGROUPS, goodguy, glist [NGROUPS];
/* rest of program deleted for clarity */

"wizard.c", line 25: error: syntax error
"wizard.c", line 25: error: syntax error
"wizard.c", line 25: error: syntax error
"wizard.c", line 25: error: syntax error: type expected for vector glist
4 errors
-- 
EMAIL:	stephen@comp.lancs.ac.uk	| Post: University of Lancaster,
UUCP:	...!mcvax!ukc!dcl-cs!stephen	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4120		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR
Re: C++ on existing C programs.
#287
Author: karl
Date: Sat, 16 Aug 1986 20:56
19 lines
1525 bytes
dcl-cs!stephen writes:
>C++ is supposed to be upwards compatible with C.  Can anybody, therefore,
>explain why the following does not compile (under 4.2):
[irrelevant portions deleted --karl]
># include <grp.h>
>int    fd = -1, wizard, group, ngroups = NGROUPS, goodguy, glist [NGROUPS];

Because <grp.h> declares "struct group", and line 25 declares "int group".
In C++, class names share the same namespace as variables -- there is, in
effect, an automatic declaration "typedef struct group group".  I think there
might be a compatibility flag to allow the collision.

In future, you might try isolating the problem by deleting chunks of code
until you have a minimal-case program that demonstrates the alleged bug.  It
makes it easier to convince the Powers That Be if it is a compiler bug, or
to find it yourself if it isn't.

Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads