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:
#!/bin/bash if [[ "$#" != 1 ]] ; then echo "Usage: stripcomments input-file" > /dev/stderr exit fi gcc -fpreprocessed -dD -E -P "$1" 2> /dev/null