DrawingProcess
๋“œํ”„ DrawingProcess
DrawingProcess
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
ยซ   2025/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (964)
    • Profile & Branding (22)
      • Career (15)
    • IT Trends (254)
      • Conference, Faire (Experien.. (31)
      • News (187)
      • Youtube (19)
      • TED (8)
      • Web Page (2)
      • IT: Etc... (6)
    • Contents (97)
      • Book (66)
      • Lecture (31)
    • Project Process (94)
      • Ideation (0)
      • Study Report (34)
      • Challenge & Award (22)
      • 1Day1Process (5)
      • Making (5)
      • KRC-FTC (Team TC(5031, 5048.. (10)
      • GCP (GlobalCitizenProject) (15)
    • Study: ComputerScience(CS) (72)
      • CS: Basic (9)
      • CS: Database(SQL) (5)
      • CS: Network (14)
      • CS: OperatingSystem (3)
      • CS: Linux (39)
      • CS: Etc... (2)
    • Study: Software(SW) (95)
      • SW: Language (29)
      • SW: Algorithms (1)
      • SW: DataStructure & DesignP.. (1)
      • SW: Opensource (15)
      • SW: Error Bug Fix (43)
      • SW: Etc... (6)
    • Study: Artificial Intellige.. (149)
      • AI: Research (1)
      • AI: 2D Vision(Det, Seg, Tra.. (35)
      • AI: 3D Vision (70)
      • AI: MultiModal (3)
      • AI: SLAM (0)
      • AI: Light Weight(LW) (3)
      • AI: Data Pipeline (7)
      • AI: Machine Learning(ML) (1)
    • Study: Robotics(Robot) (33)
      • Robot: ROS(Robot Operating .. (9)
      • Robot: Positioning (8)
      • Robot: Planning & Control (7)
    • Study: DeveloperTools(DevTo.. (83)
      • DevTool: Git (12)
      • DevTool: CMake (13)
      • DevTool: NoSQL(Elastic, Mon.. (25)
      • DevTool: Container (17)
      • DevTool: IDE (11)
      • DevTool: CloudComputing (4)
    • ์ธ์ƒ์„ ์‚ด๋ฉด์„œ (64)
      • ๋‚˜์˜ ์ทจ๋ฏธ๋“ค (7)
      • ๋‚˜์˜ ์ƒ๊ฐ๋“ค (42)
      • ์—ฌํ–‰์„ ๋– ๋‚˜์ž~ (10)
      • ๋ถ„๊ธฐ๋ณ„ ํšŒ๊ณ  (5)

๊ฐœ๋ฐœ์ž ๋ช…์–ธ

โ€œ ๋งค์ฃผ ๋ชฉ์š”์ผ๋งˆ๋‹ค ๋‹น์‹ ์ด ํ•ญ์ƒ ํ•˜๋˜๋Œ€๋กœ ์‹ ๋ฐœ๋ˆ์„ ๋ฌถ์œผ๋ฉด ์‹ ๋ฐœ์ด ํญ๋ฐœํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด๋ณด๋ผ.
์ปดํ“จํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ์ด๋Ÿฐ ์ผ์ด ํ•ญ์ƒ ์ผ์–ด๋‚˜๋Š”๋ฐ๋„ ์•„๋ฌด๋„ ๋ถˆํ‰ํ•  ์ƒ๊ฐ์„ ์•ˆ ํ•œ๋‹ค. โ€

- Jef Raskin

๋งฅ์˜ ์•„๋ฒ„์ง€ - ์• ํ”Œ์ปดํ“จํ„ฐ์˜ ๋งคํ‚จํ† ์‹œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ฃผ๋„

์ธ๊ธฐ ๊ธ€

์ตœ๊ทผ ๊ธ€

์ตœ๊ทผ ๋Œ“๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
DrawingProcess

๋“œํ”„ DrawingProcess

[Linux] C++ ์ปดํŒŒ์ผ๋Ÿฌ์— ๋Œ€ํ•˜์—ฌ (feat. clang/LLVM, clang-format, clang-tidy)
Study: ComputerScience(CS)/CS: Linux

[Linux] C++ ์ปดํŒŒ์ผ๋Ÿฌ์— ๋Œ€ํ•˜์—ฌ (feat. clang/LLVM, clang-format, clang-tidy)

2022. 8. 29. 12:52
๋ฐ˜์‘ํ˜•
๐Ÿ’ก ๋ณธ ๋ฌธ์„œ๋Š” '[Linux] C++ ์ปดํŒŒ์ผ๋Ÿฌ์— ๋Œ€ํ•˜์—ฌ (feat. clang/LLVM, clang-format, clang-tidy)'์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋†“์€ ๊ธ€์ž…๋‹ˆ๋‹ค.
C++ ํŒŒ์ผ์„ ์ปดํŒŒ์ผํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ์ปดํŒŒ์ผ๋Ÿฌ๋Š” gcc์™€ clang์ž…๋‹ˆ๋‹ค. ๋ณธ ๋ฌธ์—์„œ๋Š” clang์— ๋Œ€ํ•œ ์„ค๋ช… ๋ฐ ๊ด€๋ จ ๋„๊ตฌ๋“ค์— ๋Œ€ํ•ด ์ •๋ฆฌํ•˜์˜€์œผ๋‹ˆ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

About clang

C, C++, Obejctive-C, Obejctive-C++ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ์œ„ํ•œ ์ปดํŒŒ์ผ๋Ÿฌ ํ”„๋ก ํŠธ์—”๋“œ์ด๋ฉฐ, LLVM์„ ๋ฐฑ์—”๋“œ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ LLVM 2.6 ์ดํ›„๋กœ ๋ฆด๋ฆฌ์ฆˆ์˜ ์ผ๋ถ€๋กœ ์ž๋ฆฌ์žก์œผ๋ฉฐ, GCC(GNU ์ปดํŒŒ์ผ๋Ÿฌ ๋ชจ์Œ)๋ฅผ ๋Œ€์ฒดํ•˜๋Š” ๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

ํ˜„์žฌ GCC๊ฐ€ GPLv3๋ฅผ ์ ์šฉํ•œ ์ดํ›„ ์†Œ์Šค ์ฝ”๋“œ ๊ณต๊ฐœ๋ฅผ ๊บผ๋ฆฌ๋Š” ๊ธฐ์—…๋“ค์ด ํ•˜๋‚˜๋‘˜์”ฉ LLVM/Clang (UIUC License: ์†Œ์Šค์ฝ”๋“œ ๊ณต๊ฐœ ์˜๋ฌด ์—†์Œ)์„ ์ง€์›ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

  • LLVM
    • ์ปดํŒŒ์ผ๋Ÿฌ๋Š” ํ”„๋ก ํŠธ์—”๋“œ-๋ฏธ๋“ค์—”๋“œ-๋ฐฑ์—”๋“œ์˜ ๋‹จ๊ณ„๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ, 
      LLVM์€ ์•„ํ‚คํ…์ฒ˜๋ณ„๋กœ ๋ถ„๋ฆฌ๋œ ๋ชจ๋“ˆ์‹ ๋ฏธ๋“ค์—”๋“œ-๋ฐฑ์—”๋“œ๋ฅผ ์ค‘์ ์œผ๋กœ ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๋”ฐ๋ผ์„œ LLVM์€ ํ”„๋ก ํŠธ์—”๋“œ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋“ค์„ ์ค‘๊ฐ„ ํ‘œํ˜„ ์ฝ”๋“œ๋กœ ๋ฐ”๊ฟ”๋†“์œผ๋ฉด,
      ์ด๋ฅผ ๊ฐ๊ฐ์˜ ์•„ํ‚คํ…์ฒ˜์— ๋งž๊ฒŒ ์ตœ์ ํ™”ํ•˜์—ฌ ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ๋ฐ”๊พธ๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.
  • LLVD
    • LLVM ํ”„๋ก ํŠธ์—”๋“œ์— ๋Œ€์‘ํ•˜๋Š” ๋””๋ฒ„๊ฑฐ.
    • GCC์˜ GDB์™€ ๋™์ผํ•œ ํฌ์ง€์…˜์„ ๊ฐ–๊ณ  ์žˆ์œผ๋ฉฐ, ์• ํ”Œ Xcode 5.0 ์ด์ƒ์˜ ๋ฒ„์ „์—์„œ ๊ธฐ๋ณธ ๋””๋ฒ„๊ฑฐ๋กœ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

About clang-format

C/C++/Objective-C ์ฝ”๋“œ ์ž๋™ ์„œ์‹ ๋งž์ถค ๋„๊ตฌ๋กœ ์ฝ”๋“œ์˜ ์ตœ์ƒ๋‹จ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ .clang-format์„ ๋‘”๋‹ค๋ฉด ์ฝ”๋”ฉ ์ปจ๋ฒค์…˜(coding convention)์„ ๊ฐ•์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ฝ”๋”ฉ ์ปจ๋ฒค์…˜์ด๋ž€? ์–ด๋–ค ๊ทœ์น™์œผ๋กœ ํ”„๋กœ๊ทธ๋žจ์„ ์ˆ˜ํ–‰ํ• ์ง€์— ๋Œ€ํ•œ ๊ทœ์•ฝ์ž…๋‹ˆ๋‹ค.

BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0
AccessModifierOffset: -4

์ฝ”๋”ฉ์ปจ๋ฒค์…˜ ์ž๋™ ์ ์šฉ: ์ €์žฅ, ํƒ€์ดํ•‘, ํƒญ์„ ํ•  ๊ฒฝ์šฐ ์ ์šฉ.

  • ๋‹ค์Œ์˜ ๋‚ด์šฉ์„ .vscode/settings.json ๋‚ด ์„ค์ •ํ•˜์—ฌ, ์ €์žฅ-ํƒ€์ดํ•‘-๋ถ™์—ฌ๋„ฃ๊ธฐ ๋“ฑ์„ ํ•  ๋•Œ์— ์ฝ”๋”ฉ ์ปจ๋ฒค์…˜์ด ๊ฐ•์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
// Coding convention
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true

ํŠน์ • ํŒŒ์ผ์— clang-format ์ ์šฉ

1. ํŠน์ • style guide ์ ์šฉ (predefined style)

clang-format -style=google -i path/to/file.cpp

2. ํŠน์ • style guide๋ฅผ ์ผ๋ถ€ ๋ณ€ํ˜•ํ•œ .clang-format ํŒŒ์ผ ์ ์šฉ (custom style)

ํŠน์ • style guide๋ฅผ dump ํ•˜์—ฌ .clang-format ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

clang-format -style=google -dump-config > .clang-format

clang format sytle options์— ๋”ฐ๋ผ ํ•ญ๋ชฉ์„ ์›ํ•˜๋Š”๋Œ€๋กœ ๋ณ€๊ฒฝ ํ›„ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ํŠน์ • ํŒŒ์ผ์— ์ ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

clang-format -i path/to/file.cpp
  • one can either use one of the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft)
    • LLVM A style complying with the LLVM coding standards
    • Google A style complying with Google’s C++ style guide
    • Chromium A style complying with Chromium’s style guide
    • Mozilla A style complying with Mozilla’s style guide
    • WebKit A style complying with WebKit’s style guide
    • Microsoft A style complying with Microsoft’s style guide
    • GNU A style complying with the GNU coding standards

About clang-tidy

์Šคํƒ€์ผ ์œ„๋ฐ˜, ์ธํ„ฐํŽ˜์ด์Šค ์˜ค์šฉ ๋˜๋Š” ์ •์  ๋ถ„์„์„ ํ†ตํ•ด ์ถ”๋ก ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฒ„๊ทธ์™€ ๊ฐ™์€ ์ผ๋ฐ˜์ ์ธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์˜ค๋ฅ˜๋ฅผ ์ง„๋‹จํ•˜๊ณ  ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•œ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ๋ณดํŽธ์ ์œผ๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค๋ช…ํ•˜๋ฉฐ, ์—ฌ๊ธฐ์„œ 'linter'๋ž€? ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ํ”„๋กœ๊ทธ๋žจ ์˜ค๋ฅ˜, ๋ฒ„๊ทธ, ์Šคํƒ€์ผ ์˜ค๋ฅ˜, ์˜์‹ฌ์Šค๋Ÿฌ์šด ๊ตฌ์กฐ์ฒด์— ํ‘œ์‹œ(flag)๋ฅผ ๋‹ฌ์•„๋†“๊ธฐ ์œ„ํ•œ ๋„๊ตฌ๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค.

clang-based C++ “linter” tool

How do you install clang-format on macOS?

clang์€ macOS์— ์„ค์น˜๋˜๋ฉฐ ๊ธฐ๋ณธ ์ปดํŒŒ์ผ๋Ÿฌ์ด์ง€๋งŒ clang-format ๋˜๋Š” clang-tidy (๋˜๋Š” ์ถ”๊ฐ€ ๋„๊ตฌ)์™€ ํ•จ๊ป˜ ์„ค์น˜๋˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค. ์›ํ•˜๋Š” ๊ฒฝ์šฐ Brew๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ brew install clang-format
$ brew install fmenezes/tap/clang-tidy

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹(fmenezes/tap/clang-tidy)์œผ๋กœ ์„ค์น˜ํ•˜๋ฉด Ubuntu์—์„œ์™€ ๋™์ผํ•œ CMake ํŒŒ์ผ์„ ๋นŒ๋“œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ macOS์—์„œ clang-tidy๋ฅผ ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ llvm๊นŒ์ง€ ์„ค์น˜ํ•œ ๋‹ค์Œ, ์‚ฌ์šฉํ•˜๋ ค๋Š” ๋„๊ตฌ์— ๋Œ€ํ•œ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์„ค์ •ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

$ brew install llvm
$ ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
$ ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"

+ ๊ธฐ๋ณธ clang ์ปดํŒŒ์ผ๋Ÿฌ์™€์˜ ์ถฉ๋Œ๋กœ ์ธํ•ด ๋ชจ๋“  llvm์„ PATH์— ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์€ ์ข‹์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

# ์ฐธ๊ณ 

  • [Official Docs] clang official guideline: https://clang.llvm.org/extra/clang-doc.html
  • [Blog] macOS์— clang-tidy๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?: 
    https://www.wake-up-neo.com/ko/macos/macos%EC%97%90-clangtidy%EB%A5%BC-%EC%84%A4%EC%B9%98%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95%EC%9D%80-%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C/808393026/
  • [StackOverFlow] How to install clang-tidy on macOS?
    https://stackoverflow.com/questions/53111082/how-to-install-clang-tidy-on-macos
๋ฐ˜์‘ํ˜•
์ €์ž‘์žํ‘œ์‹œ ๋น„์˜๋ฆฌ ๋ณ€๊ฒฝ๊ธˆ์ง€ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'Study: ComputerScience(CS) > CS: Linux' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Linux] ๋ผ์šฐํŒ…(Routing) ์ด๋ž€? ๋ฆฌ๋ˆ…์Šค ๋ผ์šฐํŒ… ์„ค์ • (feat. route)  (2) 2022.10.07
[Linux] NTP ์„œ๋ฒ„ ์‹œ๊ฐ„ ๋™๊ธฐํ™”  (0) 2022.09.28
[Linux] Executable and Linkable Format(ELF): ์‹คํ–‰ ๋ฐ ๋งํ‚น ํŒŒ์ผ ํฌ๋งท (feat. readelf)  (0) 2022.08.23
[Linux] ์ผ์ • ์‹œ๊ฐ„๋งˆ๋‹ค ์ž‘์—… ์‹คํ–‰์‹œํ‚ค๊ธฐ(crontab)  (0) 2022.08.12
[Linux] ln ๋ช…๋ น์–ด(feat. ๋ฆฌ๋ˆ…์Šค ํŒŒ์ผ ๋งํ‚น): ํ•˜๋“œ๋งํฌ(Hard Link) VS ์‹ฌ๋ณผ๋ฆญ๋งํฌ(Symbolic Link)  (0) 2022.08.09
    'Study: ComputerScience(CS)/CS: Linux' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • [Linux] ๋ผ์šฐํŒ…(Routing) ์ด๋ž€? ๋ฆฌ๋ˆ…์Šค ๋ผ์šฐํŒ… ์„ค์ • (feat. route)
    • [Linux] NTP ์„œ๋ฒ„ ์‹œ๊ฐ„ ๋™๊ธฐํ™”
    • [Linux] Executable and Linkable Format(ELF): ์‹คํ–‰ ๋ฐ ๋งํ‚น ํŒŒ์ผ ํฌ๋งท (feat. readelf)
    • [Linux] ์ผ์ • ์‹œ๊ฐ„๋งˆ๋‹ค ์ž‘์—… ์‹คํ–‰์‹œํ‚ค๊ธฐ(crontab)
    DrawingProcess
    DrawingProcess
    ๊ณผ์ •์„ ๊ทธ๋ฆฌ์ž!

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”