docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합

이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
Antigravity Agent
2026-07-05 00:39:13 +09:00
parent 9148c358d0
commit e9cbf23ab5
1356 changed files with 0 additions and 12831 deletions
@@ -0,0 +1,76 @@
---
id: c-organize-code
title: "C Organize Code"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["header files", "include guard", "modular programming", "C 코드 조직화"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.85
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["c", "programming-language", "w3schools", "header-files", "modular-programming"]
raw_sources: ["https://www.w3schools.com/c/c_organize_code.php"]
applied_in: []
github_commit: ""
---
# [[C Organize Code]]
## 🎯 한 줄 통찰 (One-line insight)
The `#ifndef`/`#define`/`#endif` include guard exists to solve a problem that's invisible in small single-file programs but inevitable in multi-file ones — preventing the SAME header from being included twice (directly or transitively through other headers) which would otherwise cause duplicate-declaration compile errors, making the include guard a defensive pattern every C header should carry regardless of whether the problem has actually occurred yet. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Modular programming** — splitting code into smaller, reusable `.c`/`.h` file pairs for readability, maintainability, and debuggability; optional for small programs, valuable for larger ones. [S1]
- **Header files (`.h`)** — declare functions, share variables/constants/macros across files, and organize code into logical modules; typically contain declarations, macros, and struct definitions (not full function bodies). [S1]
- **Include guard (`#ifndef`/`#define`/`#endif`)** — prevents a header from being included more than once by accident, avoiding duplicate-declaration errors; a standard, recommended practice in every C header. [S1]
- **Separation of declaration and definition** — the `.h` file declares function signatures; the corresponding `.c` file provides the actual function bodies. [S1]
- **Multi-file compilation** — the compiler must be given ALL relevant `.c` files at once (e.g. `gcc main.c calc.c -o program`) to link them into one executable. [S1]
## 📖 세부 내용 (Details)
- Header file with include guard: `#ifndef CALC_H #define CALC_H int add(int x, int y); int subtract(int x, int y); #endif` (calc.h). [S1]
- Corresponding source file: `#include "calc.h" int add(int x, int y) { return x + y; } int subtract(int x, int y) { return x - y; }` (calc.c). [S1]
- Consuming the module: `#include <stdio.h> #include "calc.h" int main() { printf("5 + 5 = %d\n", add(5, 5)); printf("6 - 4 = %d\n", subtract(6, 4)); return 0; }` (main.c). [S1]
- Compiling multiple files together: `gcc main.c calc.c -o program`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **include guard의 필요성**: 작은 프로그램에서는 문제가 드러나지 않지만, 헤더가 여러 파일에서 직간접적으로 중복 포함될 경우 중복 선언 에러가 발생할 수 있어 모든 C 헤더에 include guard를 넣는 것이 표준 관행으로 권장됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — calc.h/calc.c/main.c로 나눈 계산기 모듈 예제가 여러 파일로 나뉜 프로그램을 gcc로 함께 컴파일하는 실전 워크플로우를 그대로 보여준다. [S1]
## 💻 코드 패턴 (Code patterns)
A header file with an include guard, plus the gcc command to compile the multi-file project (C):
```c
// calc.h
#ifndef CALC_H
#define CALC_H
int add(int x, int y);
int subtract(int x, int y);
#endif
```
```bash
gcc main.c calc.c -o program
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.85
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Comments]], [[C Functions]], [[C Variables]]
- **참조 맥락:** Basics 섹션 마지막 — 변수(Variables) 섹션으로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — C Organize Code — https://www.w3schools.com/c/c_organize_code.php
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C Organize Code" page (Astra wiki-curation, P-Reinforce v3.1 format).