new cdecl for ANSI C and C++ sent to comp.sources.unix

Tony L. Hansen hansen at pegasus.UUCP
Thu Feb 11 13:20:02 AEST 1988


I've just sent to comp.sources.unix a new version of cdecl which adds
support for the new features of ANSI C and C++, as well as maintaining all
the old features of the old cdecl program. This includes all the new
keywords for the two new languages and function prototypes. The program
compiles on System V, 4.2BSD and MS-DOS; see the makefile for more
information on the different environments.

Here are the comments from the program which list all of the changes made.

/*
 * cdecl - ANSI C and C++ declaration composer & decoder
 *
 *	originally written
 *		Graham Ross
 *		once at tektronix!tekmdp!grahamr
 *
 *	modified to provide hints for unsupported types
 *	added argument lists for functions
 *	added 'explain cast' grammar
 *	added #ifdef for 'create program' feature
 *		???? (sorry, I lost your name and login)
 *
 *	conversion to ANSI C
 *		David Wolverton
 *		ihnp4!houxs!daw
 *
 *	merged D. Wolverton's ANSI C version w/ ????'s version
 *	added function prototypes
 *	added C++ declarations
 *	made type combination checking table driven
 *	added checks for void variable combinations
 *	made 'create program' feature a runtime option
 *	added file parsing as well as just stdin
 *	added help message at beginning
 *	added prompts when on a TTY or in interactive mode
 *	added getopt() usage
 *	added -a, -r, -p, -c, -d, -D, -V, -i and -+ options
 *	delinted
 *	added #defines for those without getopt or void
 *	added 'set options' command
 *	added 'quit/exit' command
 *	added synonyms
 *		Tony Hansen
 *		attmail!tony, ihnp4!pegasus!hansen
 */

Here is a portion of the manual page:

     NAME
	  cdecl, c++decl - Compose C and C++ type declarations

     SYNOPSIS
	  cdecl	[-a | -+ | -p |	-r] [-cidDV] [files ...]

	  c++decl [-a |	-+ | -p	| -r] [-cidDV] [files ...]

     DESCRIPTION
	  Cdecl	(and c++decl ) is a program for	encoding and decoding
	  C (C++) type-declarations.  The C language (the default for
	  cdecl	, or with the -a option) is based on the (draft
	  proposed) X3J11 ANSI Standard; optionally, the C language
	  may be based on the pre-ANSI definition defined by Kernighan
	  & Ritchie's The C Programming	Language book (the -p option
	  is used), or the C language defined by the Ritchie PDP-11 C
	  compiler (the	-r option is used).  The C++ language (the
	  default for c++decl ,	or with	the -+ option) is based	on
	  Stroustrup's The C++ Programming Language, plus the version
	  2.0 additions	to the language.

	  Cdecl	reads the named	files for statements in	the language
	  described below.  A transformation is	made from that
	  language to C	(C++) or pseudo-English.  The results of this
	  transformation are written on	standard output.  If no	files
	  are named, or	a filename of ``-'' is encountered, standard
	  input	will be	read.  If standard input is coming from	a
	  terminal, (or	the -i option is used),	a prompt will be
	  written to the terminal before each line.

     COMMAND LANGUAGE
	  There	are six	statements in the language.  The declare
	  statement composes a C type-declaration from a verbose
	  description.	The cast statement composes a C	type-cast as
	  might	appear in an expression.  The explain statement
	  decodes a C type-declaration or cast,	producing a verbose
	  description.	The help (or ?)	 statement provides a help
	  message.  The	quit (or exit) statement (or the end of	file)
	  exits	the program.  The set statement	allows the command
	  line options to be set interactively.

	  Some synonyms	are permitted during a declaration:  character
	  -> char, constant -> const, enumeration -> enum, func	->
	  function, integer -> int, ptr	-> pointer, ref	-> reference,
	  ret -> returning, structure -> struct, and vector -> array.

					Tony Hansen
				ihnp4!pegasus!hansen, attmail!tony



More information about the Comp.unix.wizards mailing list