Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • perl solution have problem with multi line: test it with this output => echo -e "BEGIN/*comment*/ COMMAND /*com\nment*/END" Commented Jul 21, 2016 at 14:18
  • @Babby, works for me. I've added a multi-line comment and the resulting output in my test case. Commented Jul 21, 2016 at 14:28
  • The best thing to compare to nowadays would be gcc -std=c11 -E -P (-ansi is just another name for -std=c90). Commented Jul 21, 2016 at 17:16
  • @zwol, the idea is to be able to handle code written for any C/C++ standard (c90, c11 or other). Strictly speaking, it's not possible (see my 2nd contrived example). The code still tries to handle C90 constructs (like ??'), hence we compare with cpp -ansi for those and C99/C11... one (like // xxx), hence we compare with cpp (or cpp -std=c11...) Commented Jul 21, 2016 at 17:29
  • @zwol, I've split the test case in an attempt to clarify a bit. It looks like trigraphs are still in C11, so my second test case is not standard C anyway. Commented Jul 21, 2016 at 17:47