Subject: Re: '//' for comments in C code? (archivers/unace)
To: None <tech-pkg@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-pkg
Date: 01/21/2004 21:48:15
In article <E1AjP6Y-0005GA-0R@mikro.physik.TU-Berlin.DE>,
Georg Schwarz <geos@epost.de> wrote:
>> >What would be the best way to accompish that? 
>> 
>> 1. Use gcc
>
>sure, that would be an option, but I think it would be an unnecessary
>restriction.
>
>> 2. tell the author not to use C99 features
>
>apparently the only feature used are the // comments.
>
>> 3. add a pre-processing step that uses gnu cpp or awk to strip the
>>    // comments
>
>That's exactly what I had had in mind. How could this best be accomplished
>(using awk, for example)? And how would one add it to the Makefile?

Sed seems simpler:


.c.o:
	@(echo ${CC} ${CFLAGS} -c $< && \
	PID=$$$$ && \
	sed -e 's,//.*$$,,' < $< > tmp$${PID}.c && \
	${CC} ${CFLAGS} -c tmp$${PID}.c && \
	mv tmp$${PID}.o $@ && \
	rm -f tmp$${PID}.c)

I would have used /dev/stdin, but some cc's check that the file ends in .c

christos