We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# filename: strip_c_comment.awk # issue: awk -f scrip_c_comment.awk test.c BEGIN { FS="" } !(ignore_line && $NF == "\\") && !ignore_line-- { ignore_line = 0; for(i = 1; i <= NF; i++) { if (ignore_block) { if ($i $(i+1) == "*/") { ignore_block = 0 i++ # remove '*' } continue } if (!instr && $i $(i+1) == "/*") { ignore_block = 1 i++ # remove '/' continue } if (!instr && $i $(i+1) == "//") { ignore_line = ($NF == "\\")? 1: 0 break } if ($i == "\"") { instr = 1 - instr } printf($i) } printf("\n") }
用awk去除C语言注释。 https://blog.51cto.com/onlyzq/546456
The text was updated successfully, but these errors were encountered:
简单点的
调用预处理器 cpp 来过滤
sed 's/^#/@/' main.c | cpp | sed -e '/#/d' -e 's/@/#/'
Sorry, something went wrong.
No branches or pull requests
用awk去除C语言注释。
https://blog.51cto.com/onlyzq/546456
The text was updated successfully, but these errors were encountered: