9a135bd19d
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
4.0 KiB
4.0 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| c-macros | C Preprocessor and Macros | Programming_Language | draft | conceptual |
|
B | 0.86 | 2026-07-04 | 2026-07-04 |
|
|
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 ofNAMEin the code is textually replaced withvaluebefore 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; }— ifDEBUGwere 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):
#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).