On Thu, Dec 06, 2018 at 03:26:20AM +0100, Vincent Lefevre wrote: > On 2018-12-05 20:43:43 +0000, Jonathan Wakely wrote: > > On Wed, 5 Dec 2018 at 20:43, Segher Boessenkool > > <segher@xxxxxxxxxxxxxxxxxxx> wrote: > > > > > > On Wed, Dec 05, 2018 at 06:37:55PM +0000, Jonathan Wakely wrote: > > > > On Wed, 5 Dec 2018 at 16:44, Vincent Lefevre <vincent+gcc@xxxxxxxxxx> wrote: > > > > > > > > > > I would like to write a gcc wrapper and get the list of input files > > > > > of the gcc command line before executing gcc. As a heuristic, I could > > > > > get all the arguments with some extension like .c and .h, but is > > > > > there a more reliable way? > > > > > > > > Look for any argument that doesn't start with '-' or '@' ? > > > > > > Some options take a filename as a separate argument. Like "-o that.o". > > > > D'oh, of course. > > However, I probably wouldn't miss any input file, because all of them > are actually full arguments (i.e. nothing like -Idir for files). If > the wrapper considers other files like in "-o that.o", this is not an > issue, because it is unlikely that such files have been opened in a > text editor, and directories are not an issue either since one can > easily skip them. It won't miss any input files from people who didn't write weird command lines. But, for example, you can do "gcc a.c -includea.h" (note no space after the -include), and that works. Segher