The Compliation Process
PreProcessor는 source code 가 translator 에서 object code 로 translate 되기 전에 run 한다.
tokens 문자에만 반응한다. ex #
코드들을 치환시킨다.
Preprocessed output files 는 .i 파일로 나타난다.
파일을 보기위한 명령어는 Clang, gcc, Visual C++ 별로 command 가 다르다.
File Inclusion
#include
어떤 source file의 내용을 다른 source file 에 insert 할 수 있다.
insert 하는 파일을 header file 이라 칭한다.
#include <foo.h>
컴파일러 라이브러리 폴더
#include "foo.h"
현재 디렉토리 -> 파일 못찾으면 컴파일러 라이브러리 폴더
Conditional Inclusion
#if, #elif, #else #endif
inducing error
#error
Header Guard
#ifndef BAR_H
#define BAR_H
int func(void) return 1;
#endif
Macro Definition
#define identifier replacement-list
replacement가 비어있으면
code -> remove
command -> 1
● object-like macro
● function-like macro
\ (back slash) -> 줄바꿈 가능
identifier 는 중복해서 사용 불가
#define에 사용했다면, 코드 상에서 더이상 함수나 변수로 선언이 불가능 하다.
Macro Replacement
- Stringizing
#define STRINGIZE(x) #x
macro rescan 매커니즘
After expanding the macro ...
- rescan 할 때 preprocessing directive 가 나타나도 치환하지 않는다
Atomic....
쪼갤 수 없도록 하나의 과정으로 묶는다
멀티쓰레드 상황에서 context switching이 일어날 때 하나의 어떤 연산이 끝나기 전에 다른 Thread로 넘어가서 예상하지 못한 상황이 발생하는 경우를 막아준다.
Volatile
컴파일러에게 해당 변수관련해서는 '최적화'하지 않도록 명력
'프로그래밍 > Study C' 카테고리의 다른 글
Debugging, Testing and Analysis (0) | 2022.11.07 |
---|---|
'Static' in C language (0) | 2022.10.27 |
Program Structure (0) | 2022.10.19 |
Buffer (0) | 2022.10.11 |
I/O Stream (0) | 2022.10.11 |
댓글