Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jan 2002 16:59:38 +0100
From:      Cliff Sarginson <cliff@raggedclown.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: CVSup release info
Message-ID:  <20020131155938.GA1512@raggedclown.net>
In-Reply-To: <047201c1aa24$6423d8e0$b300a8c0@wenk>
References:  <20020131031616.GA73680@hades.hell.gr> <047201c1aa24$6423d8e0$b300a8c0@wenk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 30, 2002 at 10:56:21PM -0800, Jeff Shevlen wrote:
> That's interesting.  I had no idea shell scripts could interface with
> C like so.  I have one last question in regards to the script. I
> looked at man cpp and I didn't see anything about  "-E"; not to
> mention the " -" after the E.  What does all this do?  I ran the
> script without any modifiers to cpp and I got the same result as with
> "-E -" !
> 
> : > : $ ( echo '#include <sys/param.h>' ; echo __FreeBSD_version ) |
> cpp -E - | tail -1
> : > : 500028
> :
> : Ah but it is simple really.  cpp(1) is a preprocessor.  It doesn't
> : care if input comes from standard input.  The symbol
> _FreeBSD_version
> : is defined in /usr/src/sys/sys/param.h (which finally is copied by
> : installworld to /usr/include/sys/param.h).  The two 'echo' commands
> : produce a minimal C 'testbed' like below:
> :
> : $ ( echo '#include <sys/param.h>' ; echo __FreeBSD_version )
> : #include <sys/param.h>
> : __FreeBSD_version
> :
> : This piped into cpp, will be preprocessed, and __FreeBSD_version
> (the
> : last line of the source) be substituted with it's value as defined
> in
> : /usr/include/sys/param.h.  The final tail is fairly obvious now...
> :
> : --
Mmm, I hate to be a killjoy, couldn't you do this with grep ?
Just a passing thought :)

-- 
Regards
Cliff



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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