TangSiyang2001 opened a new issue, #44400:
URL: https://github.com/apache/doris/issues/44400

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   ** For *.h files
   Wrap the .h with "common/compile_check_begin.h" and 
"common/compile_check_end.h".
   
   ** For *.cpp files
   Including "common/compile_check_begin.h" allows for internal compilation 
checks within the current cpp file.
   Note that it should be placed under a namespace to avoid formatting checks 
on other included .h files as well.
   
   ** Our goals
   Avoid some precision lost and cast them if sure to be safe.
   
   ** How to find problems
   ```bash
   #!/bin/bash
   
   # 指定要遍历的文件目录
   DIR=$1
   
   # 遍历 .h 和 .cpp 文件
   find "$DIR" -type f \( -name "*.h" -o -name "*.cpp" \) | while read -r file; 
do
       # 检查是否已经包含 compile_check_begin.h
       if grep -q '#include "common/compile_check_begin.h"' "$file"; then
           echo "Skipping $file: already contains compile_check_begin.h."
           continue
       fi
   
       # 检查是否已经包含 compile_check_end.h
       if grep -q '#include "common/compile_check_end.h"' "$file"; then
           echo "Skipping $file: already contains compile_check_end.h."
           continue
       fi
   
       # 查找第一个 namespace 的行号
       namespace_line=$(grep -n '^namespace' "$file" | head -n 1 | cut -d: -f1)
   
       if [ -z "$namespace_line" ]; then
           echo "Skipping $file: no namespace found."
           continue
       fi
   
       # 在第一个 namespace 下插入 compile_check_begin.h
       sed -i "${namespace_line}a #include \"common/compile_check_begin.h\"" 
"$file"
   
       # 在文件最后一个 } 的上一行插入 compile_check_end.h
       last_brace_line=$(grep -n '^[[:space:]]*}' "$file" | tail -n 1 | cut -d: 
-f1)
       if [ -n "$last_brace_line" ]; then
           sed -i "${last_brace_line}i #include \"common/compile_check_end.h\"" 
"$file"
       else
           echo "Skipping $file: no closing brace found."
       fi
   
       echo "Processed $file."
   done
   ```
   Run the bash script above, then compile be, then problems wiill be printed 
out.
   
   ### Solution
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to