find ./ -name .c -exec grep -E '^\s#if|^\s*#elif' {} ; > ./tmp
找宏
cat ./tmp | grep -E '^\s#[^\\/]+' -o >> ./tmp2
找各行#后面不是接//注释的
cat ./tmp | grep -E '^\s#[^\\/]+' -o | sed -r 's!&&|||!\n!g' >> ./tmp3
使用!代替/进行替换,但要转义||
cat ./tmp | grep -E '^\s#[^\\/]+' -o | sed -r 's!&&|||!\n!g' | sed -r 's!#
[a-z]+ | defined | \( |\) | \s+ | ! | [0-9]\s* (> | < | = | <= | >= | ==)
\s[0-9] | \s* | "!g'
cat ./tmp3 | sed -r 's! #[a-z]+ | defined | \( | \) | \s+ | ! | [0-9]\s
(> | < | = | <= | >= | ==)\s[0-9] | \s* | " !!g ' >> ./tmp4
cat ./tmp4 | sed -r '/^(0|1)?$$/d' >> ./tmp5
cat ./tmp5 | sort -u >> ./tmp6
cat ./tmp6 | sed -r 's/(.*)/-U\1/g' >> ./defined.all
echo $(CFLAGS) | sed -r 's/(-[a-zA-Z]) / \n\1 /g' >>./tmp7
cat ./tmp7 | grep -E '(-D|-U).*' -o >>./tmp8
cat ./tmp8 | sed -r 's/=.*|\s+//g' > ./defined;
rm ./tmp*;