From: John Love-Jensen <eljay@adobe.com>
To: Tathagato Rai Dastidar <Tathagato.Rai.Dastidar@nsc.com>,
MSX to GCC <gcc-help@gcc.gnu.org>
Subject: Re: Making gcc read from the standard input
Date: Thu, 11 Jan 2007 13:56:00 -0000 [thread overview]
Message-ID: <C1CB9E1F.1B2D9%eljay@adobe.com> (raw)
In-Reply-To: <45A5D958.50100@nsc.com>
Hi Tathagato,
[Removed gcc@gcc.gnu.org reply-to]
> Is there a way I can make GCC read a C or C++ code from the standard input
> instead of from a file?
Yes, definitely. :-)
I do this (an Eljay original!), for example, to use GCC's preprocessor to
grep for Carbon API information:
carbon ()
{
echo '#include <Carbon/Carbon.h>' \
| g++ -H -x c++ -c -o /dev/null - 2>&1 \
| sed -e 's/^[. ]*//' \
| sort -u \
| tr '\n' '\0' \
| xargs -0 grep "$@"
}
Notice the g++ line? I'm using the -x c++ to specify "interpret as C++",
and the - all by itself means "source comes from stdin".
I'm sending output to /dev/null, since I really just want the -H information
for this little quick-and-dirty Carbon grep'per.
HTH,
--Eljay
next prev parent reply other threads:[~2007-01-11 13:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-11 6:31 Tathagato Rai Dastidar
2007-01-11 9:12 ` Paolo Bonzini
2007-01-11 13:56 ` John Love-Jensen [this message]
2007-01-11 17:06 ` Mike Stump
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C1CB9E1F.1B2D9%eljay@adobe.com \
--to=eljay@adobe.com \
--cc=Tathagato.Rai.Dastidar@nsc.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).