Re: Squashing C Source

Lee Woodbury <>
Mon, 17 Dec 90 13:17:53 EST

          From comp.compilers

Related articles
Squashing C Source (H T Fallside) (1990-12-05)
Re: Squashing C Source (1990-12-11)
Re: Squashing C Source megatest! (1990-12-14)
Re: Squashing C Source (1990-12-17)
Re: Squashing C Source (H T Fallside) (1990-12-17)
Re: Squashing C Source (Lee Woodbury) (1990-12-17)
Re: Squashing C Source (1990-12-18)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Lee Woodbury <>
Keywords: optimize
Organization: Compilers Central
Date: Mon, 17 Dec 90 13:17:53 EST

In article <> H T Fallside <> writes:
>I'm after a preprocessor that will do in-line expansion of procedure
>calls IN SOURCE for C to produce one lovely long main() procedure,
>something capable of dealing intelligently with parameters and local
>variables. Anyone out there got any ideas before I start writing ?

In late 1987, this fellow

Steven McGeady
3714 SE 26th Ave.
Portland, OR 97202
(503) 235-2462
(503) 696-4393

posted source to comp.sources.unix for a program called 'inline' which
did just what you wanted. I got it, saved it, and still have it, but
have never used it, so I can't tell you how good it is. The package
contained a copyright notice that prevents me from simply sending it to
you, but I have enclosed the message that accompanied the original
posting, the copyright notice, and the manual page (which the copyright
notice specifically allows me to distribute). The source itself should
still be in the comp.sources.unix archives (Volume 11, Issue 39,
Archive-name: inline/Part01...Part04); there was also a patch (Volume
11, Issue 43, Archive-name: inline/Patch1).

You may also want to consider trying to reach the author to see if he
has a more recent version.

Good luck. I would be interested to hear how useful this code is.

Leland Woodbury
USENET: ...!columbia!!leland
USMAIL: Columbia Univ., 457 CS, 500 W. 120 St., NYC 10027-6699
              TELEPHONE: 212-854-8109
FAX: 212-666-0140
: This is a shar archive. Extract with sh, not csh.
: The rest of this file will extract:
: inline.1
echo x - NN-HEADER
sed 's/^X//' > NN-HEADER << '//go.sysin dd *'
XFrom columbia!rutgers!ukma!uunet!rs Thu Sep 24 13:11:15 EDT 1987
X>From: rs@uunet.UU.NET (Rich Salz)
XNewsgroups: comp.sources.unix
XSubject: v11i039: Inline code expander for C, Part01/04
XMessage-ID: <1582@uunet.UU.NET>
XDate: 16 Sep 87 03:57:56 GMT
XOrganization: UUNET Communications Services, Arlington, VA
XLines: 852
XApproved: rs@uunet.UU.NET
XSubmitted-by: omepd!mcg@uunet.UU.NET
XPosting-number: Volume 11, Issue 39
XArchive-name: inline/Part01
X[ Please note The copyright restrictions; if you have problems with them,
X calm reasoned e-mail to Mr. McGeady will probably be most effective.
X Don't send ME mail, as I don't care enough. --r$ ]
XI have a submission for comp.sources.unix, my inline code substituter,
X'inline'. It has been in beta-test for over a month now, and I believe
Xthat it is stable enough to be released. The next four messages will
Xcontain the four shar files with the source, documentation, test files,
Xand design notes.
XA word about the copyright. I have chosen to copyright the source to
Xthe program, but place the binaries in the public domain. This is
Xpredominantly to retain control over modifications to the source and
Xover what people might do with it. The copyright notice file COPYRIGHT
Xcontains explicit permission for distribution over comp.sources, and
Xvia the archive server, but disallows other distribution. If there is
Xa problem with this, please let me know.
XThank you for your help.
XS. McGeady
X(503) 696-4393
//go.sysin dd *
echo x - COPYRIGHT
sed 's/^X//' > COPYRIGHT << '//go.sysin dd *'
XThe source code to this program ('inline') is copyrighted, and all rights
Xare reserved by the author. The copyrighted files include the C source files
Xand header files (all these files have copyright notices on them).
XRedistribution of this source code requires explicit permission from the
Xauthor. The author explicit grants permission to the comp.sources
Xmoderators to redistribute the source code to end-users. Other persons
Xwishing to redistribute this code must have permission from the author. (*)
XPermission is hereby granted to distribute the binary object code for this
Xprogram without explicit permission from the author, so long as such
Xdistribution is not for profit.
XThe Manual page for this program is hereby placed in the public domain.
XSteven McGeady
X3714 SE 26th Ave.
XPortland, OR 97202
X(503) 235-2462
X(503) 696-4393
X(*) I am taking the position that the posting of "diffs", including
Xreasonable context diffs, is "fair use", and is permitted (or at least
XI won't complain about it). However, I would prefer if all modifications
Xwere sent to me first.
//go.sysin dd *
echo x - inline.1
sed 's/^X//' > inline.1 << '//go.sysin dd *'
X.\" $Header: inline.1,v 1.8 87/06/24 13:21:28 mcg Rel $
Xinline \- C preprocessor for inline functions
X.B inline
X.B \-w
X] [
X.B \-e
X] [
X.B \-s
X] [
X.B \-n
X] [
X.B \-d
X] [
X.B \-2
X] [
X.B \-S [ em
X[ infile ] [ outfile ]
X.I Inline
Xis a
Xpreprocessor that accepts C language programs
Xcontaining the additional storage-class keyword
X\fBinline\fR applied to function declarations, and
Xgenerates identical C programs that (usually) have the
Xfunctions so marked expanded where they are called.
XInput code lacking the
X.B inline
Xkeyword is output unchanged.
X.I inline
Xallows C programmers a feature similar to that provided
Xby the C++ language.
XHowever, while the specifications are the same, the
X.I inline
Xprogram works substantially differently from currently
Ximplemented C++ compilers.
XCurrent C++ compilers rewrite
Xinline functions into expressions, thus prohibiting loops in them, but
Xallowing their use in contexts such as control statements of looping
X.I Inline
Xinline functions into code concealed in local blocks, adds
Xvariables for parameter and return values, and changes
X.B return
Xstatements into
X.BR goto s.
XThis allows use of all normal C constructs within inlines.
XThis rewriting is appropriate in all contexts except when
Xinline functions are called in the control parts of
X.B for
X.B while
Xloops, and in a few other cases.
XIn these cases, the C++ style expansion is used, and the procedures are
Xrewritten as expressions when
Xpossible (that is, when they lack loops, switches, and goto's).
X.I Inline
X.B extern
X(or, optionally,
X.BR static )
Xpredeclarations for
Xinline functions, so that unexpanded instances are compiled correctly,
Xand can be supplied externally.
XAdditionally, options are provided to emit the bodies of any unexpanded
Xfunctions as static procedures at the end of a module, or to emit
Xthe bodies of all inline functions alone, allowing inline functions to
Xbe collected into a library.
XIn normal operation,
X.I inline
Xfunctions must be declared before they are used (like C++).
XThe \-2 (two-pass) option relaxes this requirement, at a 30% penalty in
Xprocessing time.
XThe following options are provided:
X.IP \-w
Xsupress warning messages about unexpandable instances of inline functions.
X.IP \-e
Xemit predeclarations as
X.BR extern s,
Xand do not dump bodies of unexpanded functions (default).
X.IP \-s
Xemit predeclarations as
X.BR static s,
Xand dump bodies of unexpanded functions.
X.IP \-n
Xemit no predeclarations at all, and do not
Xdump bodies of unexpanded functions.
XThis allows the gathering of
X.B inline
Xfunctions into a library, to resolve unexpanded
Xreferences and any instances where the address
Xof an
X.B inline
Xwas taken.
X.IP \-d
Xdo not emit the main program, only dump the
Xbodies of all inlines (incompatible with \-e, \-s, and \-n).
X.IP \-2
Xprocess the file in two passes. This allows inline functions to be
Xdeclared after their use. For this option, standard input is not
X.IP \-S
Xemit (on the standard error output) statistics
Xabout the expansion process.
X.IP \-Se
Xemit extended statistics, giving expansion statistics
Xfor each
X.BR inline .
X.IP \-Sm
Xemit statistics about the memory usage of the program (if the program is
Xcompiled to collect these statistics).
XIf no input file is specified, the standard input is assumed,
Xand likewise for the standard output.
X.I Inline
Xdoes not perform predictably when given incorrect C programs.
XIt is easy to test a program that contains inlines with the
X cc -c -Dinline=static file.c
XWhen multiple inline functions are present in a single expression,
Xthe order in which the functions are executed in the inline code
Xis sometimes different from the order in which they would have been
Xcalled had they not been expanded.
XIn particular, all functions in the expression will be evaluated,
Xleft-to-right, before the operations in the expression are performed.
XThis is correct for most C operators,
X.I except
Xthe comma, boolean-or (||), and boolean-and (&&) operators.
XInline handles all but the comma operator correctly, expressionizing
Xcalls on the right side of the conditional operators.
X.I inline
Xattempts to pass preprocessor defines through without change,
Xit is strongly suggested that
X.I inline
Xbe executed
Xon code that has already been processed by
Xthe C preprocessor /lib/cpp.
X.I Inline
Xdoes not recognize certain degenerate cases of function declarations
Xand calls, in particular:
X (foo)(arg);
X.I Inline
Xalso does not correctly handle inline functions which take the address of
Xlabels, or which use labels other than in \fBgoto\fR statements, both
Xextremely distasteful (and probably illegal) practices.
Xcc(1), cpp(1)
X.I Inline
Xsource code
Xis Copyright, 1986, 1987 by S. McGeady, all rights reserved.
XThe binaries for the VAX version of this program and this manual page are
Xin the public domain.
XS. McGeady
X3714 SE 26th Ave.
XPortland, OR 97202
X(503) 235-2462
//go.sysin dd *


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.