This is the mail archive of the gcc-bugs@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]

Re: cpp command overwrites input files



>I've been trying to test gcc-2.95 by trying to build the NetBSD world for 
>the ARM with it, and I've found a nasty gotcha in the new cpp front-end.  
>One of the build utils in the NetBSD tree uses the cpp to pre-process 
>certain include files with the command
>
>        cpp -nostdinc -idirafter /usr/include -dM /usr/include/sys/ioctl.h 
>/usr/include/sys/ioctl_compat.h

[... and this now will overwrite ioctl_compat.h ...]

I find it difficult to believe that this command ever worked. 
/usr/lib/gcc-lib/TARGET/VERSION/cpp has treated its second non-option
argument as the output file, not another input file, for as far back as the
ChangeLog goes.  Until gcc-2.95, /bin/cpp was identical with
/u/l/g-l/T/V/cpp.  I suppose this might have been some magic property of
-dM, but it was never documented and shouldn't have been relied on.

The NetBSD utility should do

cpp -nostdinc -idirafter /usr/include -dM -include /usr/include/sys/ioctl.h \
	-include /usr/include/sys/ioctl_compat.h </dev/null

which will work with gcc-2.95 and with previous versions.  (If your target
specs are correct, you shouldn't need the -nostdinc -idirafter ... bit.)

>BTW "cpp -o -" doesn't write to stdout, nor does cpp -E.

My copy does.  Are you sure?

zw


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