Do you have a favorite method of removing C-style inline and multiline comments from code?
Removing trailing tabs that were before them and resulting double lines is a plus.
<3
Post
Do you have a favorite method of removing C-style inline and multiline comments from code?
Removing trailing tabs that were before them and resulting double lines is a plus.
<3
IIUC,
$ gcc -fpreprocessed -dD -E -P file.c > no_comments.c
should do the trick. You really need a proper C/C++ aware lexer/parser because while simple substitutions
:%s@\_s*//.*\n/\r
in Vim can get thrown off by "//" or "/*…*/" embedded in string-constants. There are additional complexities with multi-line strings and nested comments. I'm not sure if you also intend to take into consideration ": #if 0" blocks.
A space for Bonfire maintainers and contributors to communicate