Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- France
- Spain
- Malaysia
- django
- UK
- Java
- history
- hadoop
- Software Engineering
- Kuala Lumpur
- MySQL
- QT
- Programming
- leadership
- Python
- RFID
- comic agile
- Book
- management
- erlang
- program
- web
- Book review
- Linux
- ubuntu
- programming_book
- Italy
- management and leadership
- hbase
- agile
Archives
- Today
- Total
include guard 본문
2011/05/24 - [Programming/C++] - include guard
2011/05/24 - [Programming/C++] - include guard
출처: http://yesarang.tistory.com/67
include guards: 이미 읽은 헤더 파일도 다시 읽음
#pragma once: 각 파일별로 프리프로세서가 include한 상태를 기억하므로 한 번 읽은 헤더 파일은 읽지 않음. 즉 컴파일 속도 유리
include guards: 각 헤더 파일에 대응하는 매크로 이름이 서로 충돌할 가능성이 있으므로 나름의 include guards 명명 규칙이 필요
#pragma once: 프리프로세서에서 #pragma once 처리에 버그가 있거나, 파일 시스템 상에서 파일의 동일성을 파악하는 데 어려움이 있다면 문제. 예를 들어 Unix/Linux에서 hard link, soft link와 같이 서로 다른 경로명이 같은 파일을 가리키는 경우, 어쩔 수 없이 헤더 파일이 중복 포함
include guard optimization: 지금까지 설명한 include guard 는 헤더 파일 안에 관련 매크로가 정의되기 때문에 internal include guard
external include guard
#ifndef HDR_H
#include "hdr1.h"
#endif
말 그대로 헤더 파일 외부에서 guard 매크로를 테스트 이렇게 하면 internal include guard 의 문제점인 컴파일 속도 문제도 해결
2011/05/24 - [Programming/C++] - include guard
출처: http://yesarang.tistory.com/67
include guards: 이미 읽은 헤더 파일도 다시 읽음
#pragma once: 각 파일별로 프리프로세서가 include한 상태를 기억하므로 한 번 읽은 헤더 파일은 읽지 않음. 즉 컴파일 속도 유리
include guards: 각 헤더 파일에 대응하는 매크로 이름이 서로 충돌할 가능성이 있으므로 나름의 include guards 명명 규칙이 필요
#pragma once: 프리프로세서에서 #pragma once 처리에 버그가 있거나, 파일 시스템 상에서 파일의 동일성을 파악하는 데 어려움이 있다면 문제. 예를 들어 Unix/Linux에서 hard link, soft link와 같이 서로 다른 경로명이 같은 파일을 가리키는 경우, 어쩔 수 없이 헤더 파일이 중복 포함
include guard optimization: 지금까지 설명한 include guard 는 헤더 파일 안에 관련 매크로가 정의되기 때문에 internal include guard
external include guard
#ifndef HDR_H
#include "hdr1.h"
#endif
말 그대로 헤더 파일 외부에서 guard 매크로를 테스트 이렇게 하면 internal include guard 의 문제점인 컴파일 속도 문제도 해결
// hdr1.h #pragma once class DummyBase { private: int _i; public: DummyBase(int i): _i(i) {} int Get() { return _i; } void Set(int i) { _i = i; } }; // hdr2.h // same as before // tips1.cpp // same as before
Comments