title: Is there a reliable tool for removing comments in ASM/C/C++ code?
body: <p>I know this question has been asked before (e.g.: see <a href="https://stackoverflow.com/questions/2394017/remove-comments-from-c-c-code">Remove comments from C/C++ code</a>), but I haven't found any satisfiable result.</p>
  
  <p>I am parsing a set of complex C/C++ code that first must be normalized, which includes eliminating comments from the input source code.</p>
  
  <p>All decommenting tools I have tried failed to a certain degree, and that includes:</p>
  
  <ul>
  <li>decomment   </li>
  <li>stripcmt   </li>
  <li>cloc</li>
  </ul>
  
  <p>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. </p>
  
  <p>To illustrate the problem with a particular tool (cloc), removing comments from <a href="http://opencores.org/ocsvn/openrisc/openrisc/trunk/rtos/ecos-3.0/packages/hal/arm/edb7xxx/current/include/hal_platform_setup.h" rel="nofollow noreferrer">this header file</a> leads to removing non-comments as well, such as all the includes in the begining of that file.</p>
  
  <p>That said, is there any reliable tool for comment removal that can be used in stripping out comments in exceptionally complex code?</p>
  
  <p>Much appreciated.</p>