본문 바로가기
프로그래밍/C,C++

전처리기 preprocessor, 기억류 storage class

by Planetis 2015. 1. 20.
전처리기 preprocessor
#include
1
#include <stdio.h>
- 비베 기존의 헤더파일을 불러올때 해당 해더를 "<"와 ">"로 감싸준다.

1
#include "myheader.h"
- 커스텀 파일을 불러올땐, 상대경로나 절대경로를 적어주되, 이중따옴표로 감싸준다.

#define
- 컴파일시 단일문자나 문장을 상수로 혹은 명령어로 바꿈처리한다.

1
2
3
#define NUM 5
#define SUM(X, Y) x+y
#define HELLO {printf("HELLO"); printf("HELLO");}


기억류 storage class
1
2
3
4
auto int a;
register int b;
static int c;
extern int d;

auto - 일반적인 변수 선언에 사용하며 생략 가능하다.
register - CPU 메모리에 저장하는 변수로 선언 할때 사용
static - 프로그램 종료 전까지 사라지지 않는 변수를 선언 할 때
extern - 어딘가에 선언된 전역변수를 알려주는 용도. 메모리를 따로 할당하지 않는다.


320x100

댓글