I know this question has been asked before (e.g.: see Remove comments from C/C++ code), but I haven't found any satisfiable result.
I am parsing a set of complex C/C++ code that first must be normalized, which includes eliminating comments from the input source code.
All decommenting tools I have tried failed to a certain degree, and that includes:
- decomment
- stripcmt
- cloc
Note: I have also tried "gcc -fpreprocessed -E", but it does not lead to a perfect result; the output has some weird macro annotations for keeping track of certain lines of code.
To illustrate the problem with a particular tool (cloc), removing comments from this header file leads to removing non-comments as well, such as all the includes in the begining of that file.
That said, is there any reliable tool for comment removal that can be used in stripping out comments in exceptionally complex code?
Much appreciated.