This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc for syntax check only (C): need to read source from stdin


Hi,

A program I am working on generates some C code on the fly, and I
would like to check its syntax right after generation. I might save
this code fragment in a temporary file and gun gcc -c over it,
watching for exit code (0: syntax OK, 1: incorrect). This is fine with
the one exception that I have to create temporary files and then clean
them up. Does there exist any way to accompilsh this with pipes
entirely? Output object file may be discarded: I don't need it. Or I
might even use -S option to only assemble, but again, output must be
stdout, not a file (or /dev/null which does not work either: the last
program in the pipeline tries to CREATE it, not to write into it, and
fails).

Looking for verbose output from gcc -v -pipe ... I noticed that all
the components (cpp, cc1, as) are pipe-connectable (at least in most
cases). It is only the gcc (driver) which says e. g.

gcc: -E required when input is from standard input

which limits me to using preprocessor as a pipe only.

I am afraid direct invocation of cc1 may not be good because I have no
idea how its command line options are stable across various versions
of gcc.

Does there exist an alternative driver/script doing same job as the
"stock" gcc, but allowing piping its input and output?

Thank you.

-- 
Dimitry Golubovsky

Anywhere on the Web


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]