Re: gcc input files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Silverio,

> I would like to know if is possible use pipe to pass
> gcc input files instead use an actual file, eg:
> 
> cat test.c | gcc -s

Yes.  Here's how I do it:

cat foo.c | grunge | twizzle | gcc -x c - -o foo.o

Where, for example, grunge and twizzle being two custom preprocessors.  The
grunge filter acts much like the standard C preprocessor, and twizzle filter
acts much like the Objective-Whatnot preprocessor.

Here's another bash shell example...

carbongrep ()
{
 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 "$@"
}

The upshot of carbongrep is that it allows you to grep through all the
Carbon header files for some identifier.

Here's yet another example, which tells you which optimization flags are
enabled by a given optimization level, here using bash's process
substitution named pipe:

gcc -fverbose-asm -H -x c <(echo '') -O1 -S -o O1.s

HTH,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux