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,73 @@
---
id: c-macros
title: "C Preprocessor and Macros"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["#define", "#ifdef", "conditional compilation", "C 전처리기와 매크로"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.86
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["c", "programming-language", "w3schools", "preprocessor", "macros"]
raw_sources: ["https://www.w3schools.com/c/c_macros.php"]
applied_in: []
github_commit: ""
---
# [[C Preprocessor and Macros]]
## 🎯 한 줄 통찰 (One-line insight)
`#define PI 3.14` doesn't create a variable at all — the preprocessor performs a pure TEXT REPLACEMENT of every literal occurrence of `PI` with `3.14` BEFORE the compiler ever sees the code, meaning macros exist in an entirely different phase from variables/constants (which are compiled), which is also why parameterized macros like `SQUARE(x)` need careful parenthesization — they're substituting raw text, not evaluating an expression with real function-call semantics. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Preprocessor** — runs BEFORE actual compilation; handles directives (lines starting with `#`) like including files and defining macros. [S1]
- **`#include`** — angle brackets `< >` for standard libraries, double quotes `" "` for your own header files. [S1]
- **`#define NAME value`** — creates a macro; every literal occurrence of `NAME` in the code is textually replaced with `value` before compilation. [S1]
- **Parameterized macros** — `#define SQUARE(x) ((x) * (x))` behaves like a function shortcut, but is really TEXT SUBSTITUTION, so careful parenthesization is required to avoid operator-precedence mistakes. [S1]
- **`#ifdef` / `#ifndef`** — conditional compilation; includes or skips code blocks depending on whether a macro is defined, useful for debug builds or program variants. [S1]
## 📖 세부 내용 (Details)
- Basic value macro: `#define PI 3.14 int main() { printf("Value of PI: %.2f\n", PI); return 0; }`. [S1]
- Parameterized macro: `#define SQUARE(x) ((x) * (x)) printf("Square of 4: %d\n", SQUARE(4));`. [S1]
- Conditional compilation gated on a defined macro: `#define DEBUG int main() { #ifdef DEBUG printf("Debug mode is ON\n"); #endif return 0; }` — if `DEBUG` were undefined, that block would be skipped entirely. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **매크로는 변수가 아니라 텍스트 치환**: #define PI 3.14는 컴파일 전에 코드상의 PI를 문자 그대로 3.14로 바꿔치기하는 전처리 단계 작업이며, 변수나 상수처럼 컴파일되는 개념이 아니라는 점이 확인됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
DEBUG 매크로가 정의되어 있을 때만 디버그 메시지를 출력하는 조건부 컴파일이 원문에서 직접 실전 활용 사례로 제시됨(디버깅이나 프로그램 버전 분기에 유용). [S1]
## 💻 코드 패턴 (Code patterns)
Conditional compilation — code included only if a macro is defined (C):
```c
#define DEBUG
int main() {
#ifdef DEBUG
printf("Debug mode is ON\n");
#endif
return 0;
}
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.86
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Type Conversion]], [[C Organize Code]], [[C Null]]
- **참조 맥락:** 전처리기와 매크로 — NULL(Null) 챕터로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — C Preprocessor and Macros — https://www.w3schools.com/c/c_macros.php
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C Preprocessor and Macros" page (Astra wiki-curation, P-Reinforce v3.1 format).