Re: delete comments in .c file

From: Colin Newell (colin_regacct)
Date: 10/31/03


Date: Fri, 31 Oct 2003 12:27:45 -0000

Assuming you have access to the C preprocessor (cpp) you can do a quick hack
to use that. Isolate the file from it's include files and run like,

cpp -nostdinc file.c > new_file.c

It should warn that it cannot find all the include files. Now put your
#includes back in and you should have a comment free file.

This is a quick and dirty solution because the C preprocessor is trying to
do a whole load of stuff aswell as stripping comments. You need to make
sure that there are no #defines because otherwise they will be expanded out.
Put them back in after you have run the processor.

I have only come across the C preprocessor as a seperate program called
'cpp' on *nix boxes. It may be available on windows but I do not know where
or how.

Colin.

"Timex" <sugarfreed@hotmail.com> wrote in message
news:bnsegb$pi1$1@news.kreonet.re.kr...
> I want to delete all comments in .c file.
>
> Size of .c file is very big.
>
> Any good idea to do this?
>
> Please show me example code.
>
>
>



Relevant Pages

  • Re: Question about Leverage source from Different Projects
    ... conditional preprocessor stuff INSIDE the stdafx.h depending on the project macro defined. ... There is, as far as I can tell, not even a discussion of the .cpp files, just a strange ... #pragma message ...
    (microsoft.public.vc.mfc)
  • Re: Conditional compilation sans the cpp
    ... a design for some kind of macro firewall that is supposed to isolate code ... from an effects from the preprocessor. ... I fully understand that the CPP has been used to to some great stuff. ... "There is only One inviolable Law" ...
    (comp.lang.cpp)
  • Re: Cpp Considered Harmful
    ... not bring down the server. ... > library management when finally addressing the preprocessor in the ... regarding the CPP. ...
    (comp.lang.cpp)
  • Re: To bean or not to bean
    ... Qt development begain in 1991, and the first public release was on the 20th ... The preprocessor is the main reason that there is no serious C++ contender ... techniques it supports do not scale to that level of programming. ... and the Cpp than he does. ...
    (comp.lang.cpp)