[PATCH] Recognize '-' as special -MF argument (write to stdout)

Boris Kolpackov boris@codesynthesis.com
Mon May 15 07:54:00 GMT 2017


Sometimes it is useful to generate pre-processed output to a file and
the dependency information to stdout for further analysis/processing.
For example:

g++ -E -MD -fdirectives-only -o test.ii test.cxx

This will generate the dependency information to test.d (as per the
documentation). While changing this behavior is probably unwise, one
traditional (e.g., supported by -o) way to handle this is to recognize
the special '-' file name as an instruction to write to stdout:

g++ -E -MD -fdirectives-only -o test.ii -MF - test.cxx

Currently this will create a file named '-'. The included patch changes
this behavior to write to stdout.

Note also that Clang has supported this from at least version 3.5.

The patch should apply cleanly to trunk. I would also like to see it
backported to previous versions, if possible. If this requires any
additional work, I am willing to do it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mf-stdout.patch
Type: text/x-diff
Size: 1940 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20170515/e09df1bb/attachment.bin>

More information about the Gcc mailing list