페이지

2009년 6월 11일 목요일

요즘세대도 이렇게 공부하려나? C언어 이야기

요즘은 어떻게 공부하는지 모르지만,4GL이후로 1998~2000년이 될 무렵에도 BIT,BYTE도 모르는 4-5년차 4GL 프리랜서들(어이없게도 일명 중.고수급이라고 당시 4-5백/월 받던 사람들임) 을 많이 봐왔지만,,--;;
요즘은 또 어떤지 모르겠습니다. 소프트웨어 개발자를 바라는 분들은 아래에 기본기에 충실할 좋은 강좌가 있으니 꼭 열람하시기 바랍니다.

C언어 이야기 1~17장
C언어 이야기 18~22장
C언어 이야기 부록

23.C언어 관련 주요 질문과 답변
24. C언어 함수 요약
24.1.터보C 2.0 함수 요약(가나다 순)
24.2.볼랜드C++ 3.1 함수 목록(가나다순)


C언어 이야기 2부(31장부터 시작)
C언어 이야기 3부 : 예제 모음

1.컴퓨터언어와 언어 프로그램
1.1.인간 세상의 언어와 컴퓨터 세계의 언어는 같습니다
1.2.컴퓨터
언어의 구분
1.3.컴퓨터언어와 컴퓨터언어 프로그램의 차이는?
1.4.컴파일 방식과 인터프리터 방식의 차이
1.5.컴파일러가 하는 일은?


2.C언어는 어떤 언어인가
2.1.C언어의 탄생과 역사, 장점
2.2. C언어
프로그램의 대명사 터보C와 볼랜드C++에 대해서
2.3. C와 C++의 차이는?
2.4. C언어 프로그램은 왜 그리
많은가?
2.5.왜 비주얼C++이 아닌 터보C로 C언어를 배우는가?


3.프로그램 만드는 과정
3.1. 편집기와 소스 파일의 역할
3.2.컴파일러와 목적 파일(*.obj)의 역할
3.3.링커와 링크 작업

4. 볼랜드사의 컴파일러 프로그램 설치와 환경 설정

4.1.터보C와 터보C++, 볼랜드C++, 볼랜드C++ 빌더의
차이
4.2. 공개용 터보C와 터보C++ 구하기
4.2.1.터보C 2.01 다운로드 받기

4.2.2.터보C++ 1.01 다운로드 받기
4.3.터보C 설치하기
4.3.1.원판 터보C 2.0 설치하기

4.3.2.인터넷으로 받은 터보C 2.01 설치하기
4.3.3.터보C 설치 때의 문제점
4.4.
터보C 2.0의 환경설정
4.5.터보C++ 1.01 설치와 환경 설정
4.5.1.터보C++ 1.01 설치하기

4.5.2.터보C++ 1.01의 환경 설정
4.6.볼랜드C++의 설치
4.7.볼랜드C++의 환경
설정하기
4.7.1.도스용 볼랜드C++의 환경 설정하기
4.7.2.윈도용 볼랜드C++의 환경 설정하기


5.MS사의 비주얼C++ 설치와 환경 설정
5.1.비주얼C++의 특징
5.2.비주얼C++ 6.0의 처음 설치

5.3.구버전 사용자의 6.0 설치
5.4.'비주얼C++ 6.0'의 실행과 환경설정


6. 터보C로 짜보는 첫 번째 프로그램 hello.c
6.1.예제로 제공되는 hello.c 파일을 불러오는 방법

6.2.hello.c 파일을 실행 파일로 만드는 방법
6.3.hello.exe를 실행하고 확인해보는 방법


7. 도스용 볼랜드C++로 짜보는 첫 번째 프로그램 hello.c
7.1.bc.exe를 실행한 뒤에 hello.c를 불러오기

7.2.hello.c를 hello.exe로 만들기
7.3.hello.exe가 만들어졌나 확인하기


8. 윈도우용 볼랜드C++로 짜보는 첫 번째 프로그램 hello.c
8.1.윈98에서 bcw.exe를 실행하고 hello.c 파일 불러오기

8.2.hello.c 파일을 hello.exe 파일로 만들기
8.3.오류나 경고가 발생했을 때 나타나는 창

8.4.hello.exe 파일을 찾아서 실행해보기


9.'비주얼C++ 6.0'으로 짜보는 첫 번째 프로그램 hello.c
9.1.'비주얼C++ 6.0'을 실행한 뒤에 hello.c 만들기
9.2.hello.c를
불러와 hello.exe로 만들기
9.3.비주얼C++로 만든 hello.exe 실행하기


10. 내 이름이 나오는 실행 파일 만들기
10.1.터보C로 내 이름이 나오는 실행 파일 만들기
10.2.도스용 볼랜드C++(BC)에서
다른 이름으로 저장하기
10.3.내 이름이 나오는 윈도용 실행 파일 만들기


11.컴파일러의 도움말과 오류 처리
11.1.터보C의 도움말 보기
11.2.볼랜드C++의 도움말 보기
11.3.경고와
오류의 종류, 문제 해결
11.4.경고와 오류 해결하기(디버깅)


12. C언어의 기본 문법

12.1. 소스 파일과 기본문법
12.2.한글이나 영어로 주석문 달기
12.2.1.주석문의 용도

12.2.2.주석문과 명령문의 표기 방법
12.2.3.주석문의 내포와 중첩 관계
12.3.한글 문장이 출력되는
프로그램 만들기
12.4.토큰의 종류 - 키워드, 구두점, 공백문자, 이름 등
12.4.1.토큰(token)의
종류와 공백문자
12.4.2.키워드(keyword)
12.4.3.공백문자(whitespace)와 빈칸문자의
차이
12.4.4.구두점(punctuator)
12.4.5.이름(name, identifier)

12.4.6.상수(constant), 연산자(operator), 문자열(string literal)
12.5.명령문과 문장,
수식
12.5.1.문장(statement)의 개념과 범위
12.5.2.문장과 수식의 차이


13.함수 이야기
13.1.함수란 무엇인가?
13.2.함수의 기본 구조
13.3.사용자정의 함수란
무엇인가?
13.4. 내장함수, 사용자정의함수, 라이브러리의 관계
13.5.함수에 사용하는 매개변수(=인수)의 용도

13.6.매개변수 사용법
13.7.되돌림값
13.7.1.함수로부터 돌려받는 되돌림값(return
value)이란?
13.7.2.되돌림값을 사용한 함수 응용
13.8.함수 선언와 함수 정의

13.8.1.되돌림값이 없는 함수에 사용하는 void 키워드
13.8.2.함수 선언 방법
13.8.3.함수
정의와 함수 선언의 차이
13.9.함수 원형과 함수 선언, 함수 정의의 관계
13.9.1.함수의 선언을 겸한 함수
정의
13.9.2.함수 원형의 형식과 용도
13.9.3.함수 실행과 함수 호출
13.10.헤더
파일과 #include 명령
13.10.1.헤더 파일의 용도
13.10.2.#include문의 용법과
<> "" 기호의 차이
13.10.3.사용자정의 헤더 파일
13.11.getch() 함수와
conio.h 파일의 관계
13.11.1.getch()로 키 입력 때까지 멈추게 만들기

13.11.2.getch() 함수를 사용하기 위한 conio.h 헤더 파일의 추가


14.상수와 변수, 자료형

14.1. 변수와 상수의 의미, 역할
14.1.1.변수와 상수의 차이
14.1.2.scanf() 함수의
사용법과 숫자 입력받기
14.1.3.대입의 의미와 대입 연산자(=)의 역할
14.1.4.입력받은 숫자의
네제곱수 구하기
14.2.자료형의 종류와 자료형 키워드
14.3. 정수형
14.3.1.정수형의 의미

14.3.2.오버플로우와 언더플로우
14.4. 실수형
14.5. 문자형
14.6.기타
자료형
14.6.1. 열거형(Enumerated type)
14.6.2.void형
14.7.숫자
1과 문자 1은 어떻게 다른가?
14.8.단위사
14.9.상수의 자료 표기 방법


15.변수
15.1.변수를 선언하고 값을 대입해야 하는 이유
15.2. 변수 선언 규칙

15.3.변수의 정의, 초기화, 대입
15.4. 변수가 차지하는 크기
15.5.변수 사용할 때 주의할 점

15.6. 변수와 상수의 관계

16. 변수와 기억 장소

16.1. 지역 변수와 전역 변수
16.2. 기억
장소의 선언방법
16.3. 자동 변수
16.4. 외부 변수
16.5. 내부정적 변수

16.6. 외부정적 변수
16.7. 정적 함수
16.8. 레지스터 변수


17.printf(), scanf() 함수와 특수 기호 사용법
17.1.printf() 함수 사용법
17.2.scanf() 함수를
이용해 자료 입력받기
17.3.줄바꿈문자 \n의 의미
17.4.ESC따름부호(\ 기호)

17.4.1.ESC따름부호와 ESC문자열의 종류
17.4.2.8진수와 16진수를 이용한 문자 상수 표기법

17.5.대체문자 % 기호의 종류와 의미
17.6. 자료형의 변환과 캐스트 연산자
17.7.함수에 매개변수 입력하는
요령
17.8.쉼표를 이용해 여러 개의 매개변수 사용하기
17.9.printf() 함수로 자료 출력할 때 자릿수
조정하기


18. 연산자

18.1.연산자의 의미와 연산 순서
18.1.1.연산자가 하는 일

18.1.2.연산자의 우선 순위와 결합 방향
18.2. 연산자의 분류
18.2.1.연산자 수에
의한 분류
18.2.2.연산자의 기능에 따른 분류
18.3.산술 연산자 + - * / %608

18.4.대입 연산자 = += -= *= /= %=
18.5. 부호 연산자 + -
18.6.증감 연산자
++ --
18.7.관계 연산자 < <= > >= == !=
18.8.논리
연산자 ! &&
18.9. 조건 연산자 ?:
18.10.쉼표 연산자 ,

18.11.비트 연산자, 밀기 연산자 ~& ^ << >>
18.11.1.비트
연산자
18.11.2.밀기 연산자
18.12.캐스트 연산자 ()
18.13.sizeof 연산자

18.14.기타 연산자
18.14.1.번지 연산자 &
18.14.2.간접 연산자
*
18.14.3.으뜸 연산자
18.15.연산자 쓸 때 주의할 점
18.15.1.산술 변환
규칙에 대한 주의
18.15.2.부호 변환에 대한 주의
18.15.3.애매모호한 규칙에 대한 주의

19.제어문

19.1.프로그램을 제어하는 제어문의 의미와 역할
19.1.1.제어문을 이용하여 1부터 10까지 더하기

19.1.2.다른 제어문을 이용하여 1부터 10까지 더하기
19.1.3.제어문의 종류
19.2.if문

19.2.1.'만약'이라는 가정을 활용하는 조건문인 if문
19.2.2.if문을 이용한 홀수 짝수 판별

19.2.3.if else문을 이용한 홀짝 여부 판단
19.2.4.if문과 블록 명령
19.2.5.if,
else if, else를 활용한 배수 판별
19.2.6.if문의 중첩 활용하기
19.2.7.if문과 조건
연산자의 용법 비교
19.3. while문
19.3.1.조건이 만족할 때까지 반복하는 while 제어문

19.3.2.맴돌이(loop) 빠져 나오기
19.3.3.while문의 조건식과 맴돌이 관계

19.3.4.특정 키 입력 때까지 반복하기
19.4. do while문
19.4.1.~인 동안 ~을 해라(do
while)
19.4.2.do while문의 조건식과 맴돌이 관계
19.5. for문

19.5.1.for문의 사용 형식
19.5.2.for문의 구조와 특징
19.5.3.for문의 효용성

19.6. switch문
19.6.1.여러 개 중에서 하나를 고르는 switch문

19.6.2.switch문의 특징
19.7. 무한 맴돌이와 맴돌이를 탈출하는 방법
19.8. 맴돌이를 중첩해서 활용하는
방법
19.9.탈출문, 이동문
19.9.1.제어문 블록을 벗어나는 탈출문인 break문

19.9.2.반복순환문의 조건식으로 되돌아가는 continue문
19.9.3. 가고 싶은 곳으로 이동시켜주는 goto문

20. 선행처리기 명령어와 헤더 파일
20.1.선행처리기가 하는 일
20.2. #include

20.3. #define, #undef
20.4. #if, #ifdef, #else, #elif, #endif

20.5. typedef
20.6. #line, #error, #pragma
20.7. ##
20.8.
선행처리기 명령어(매크로 명령어) 사용 때 주의할 점


21.
배열

21.1. 배열의 의미
21.2. 배열의 선언와 정의

21.3.일차원 배열과 다차원 배열의 차이
21.4. 문자열 상수와 문자배열 상수

22. 번지 연산자와 포인터
22.1. 번지를 알려주는
번지 연산자 &
22.2. 간접 연산자 * 와 포인터
22.3. 번지에 의한 참조와 값에 의한 참조의 차이

22.4. 포인터에 대한 내용들



[부록] 23.C언어 관련 주요 질문과 답변


[부록] 24. C언어 함수 요약
24.1.터보C 2.0 함수 요약(가나다 순)
24.2.볼랜드C++ 3.1 함수
목록(가나다순)



31. 함수에
관한 문법


31.1. main() 함수에 대하여

31.2. 함수에 관한 규칙과 관례
31.3. 근거리함수 원거리함수 거대함수에 대하여

32. 메모리 관리와 함수
32.1. 메모리 모델에 대하여
32.1.1.초소형 모델(tiny model)

32.1.2.소형 모델(small model)
32.1.3.중형 모델(medium model)

32.1.4.중소형 모델(compact model)
32.1.5.대형 모델(large model)

32.1.6.거대 모델(huge model)
32.2. 주소 또는 번지

32.3. 선입선출과 후입선출의 차이
32.4. 코드, 데이터, 스택, 힙, 큐, 데크의 의미와 차이


33. 프로젝트와 라이브러리
33.1. 프로젝트파일(prj) 이용하기

35. 배열과 포인터

35.1. 배열 사용방법

35.1.1.배열과 포인터에 대한 복습

35.1.2.외부배열, 정적배열, 자동배열의 차이와 선언 방법
35.1.3.배열 초기화와 대입의 차이

35.1.4.다차원 배열 선언 방법
35.1.5.배열의 크기 생략과 배열 크기 알아내기


35.2. 배열과 포인터의 관계

35.2.1. 포인터
변수에 다른 자료형을 붙여 선언하는 이유

52. 텍스트 프로그램 예제

52.1. 반올림 함수 만들기
52.2. 커서를 안 보이게
52.3.
도레미파솔라시도 만드는 함수
52.4. shell.c = 가장 단순한 도스나들이 기능
52.5. dosver.c =
도스 버전을 알고 싶을 때
52.6. copystr.c = 입력받은 문자를 다시 보여줌
52.7. typefile.c
= 간단한 문서파일 내용을 보여줍니다.
52.8. list.c = 파일의 내용을 보여줍니다
52.9.
copyfile.c = 텍스트파일을 복사하는 파일복사 프로그램.
52.10. att.c = 파일의 속성을 바꿉니다

52.11. ff.c = 파일을 찾아줍니다
52.12. calendar.c = 만년 달력
52.13.
cpuspeed.c = CPU 속도를 측정
52.14. fall.c = 바이러스처럼 글씨가 떨어지는 램 상주 프로그램


IT문화원 강좌. 2005년 11월 03일
[갈래: c] URL: http://www.dal.kr/chair/c/c.html


7zip plugin Api

7zip plugin Api
This API use the 7-zip dll (7z.dll) to read and write all 7-zip supported archive formats..
Reading archive:
Extract to path: with CreateInArchive(CLSID_CFormatZip) do begin
OpenFile('c:\test.zip');
ExtractTo('c:\test');
end;
Get file list: with CreateInArchive(CLSID_CFormatZip) do
begin
OpenFile('c:\test.7z');
for i := 0 to NumberOfItems - 1 do
if not ItemIsFolder[i] then
Writeln(ItemPath[i]);
end;
Extract to stream with CreateInArchive(CLSID_CFormat7z) do
begin
OpenFile('c:\test.7z');
for i := 0 to NumberOfItems - 1 do
if not ItemIsFolder[i] then
ExtractItem(i, stream, false);
end;
Extract “n” Itemsfunction GetStreamCallBack(sender: Pointer; index: Cardinal;
var outStream: ISequentialOutStream): HRESULT; stdcall;
begin
case index of ...
outStream := T7zStream.Create(aStream, soReference);
Result := S_OK;
end;
procedure TMainForm.ExtractClick(Sender: TObject);
var
i: integer;
items: array[0..2] of Cardinal;
begin
with CreateInArchive(CLSID_CFormat7z) do
begin
OpenFile('c:\test.7z');
// items must be sorted by index!
A items[0] := 0;
items[1] := 1;
items[2] := 2;
ExtractItems(@items, Length(items), false, nil, GetStreamCallBack);
end;
end;
Open stream with CreateInArchive(CLSID_CFormatZip) do
begin
OpenStream(T7zStream.Create(TFileStream.Create('c:\test.zip', fmOpenRead), soOwned));
OpenStream(aStream, soReference);
...
end;
Progress bar function ProgressCallback(sender: Pointer; total: boolean; value: int64): HRESULT; stdcall;
begin
if total then
Mainform.ProgressBar.Max := value else
Mainform.ProgressBar.Position := value;
Result := S_OK;
end;
procedure TMainForm.ExtractClick(Sender: TObject);
begin
with CreateInArchive(CLSID_CFormatZip) do begin
OpenFile('c:\test.zip');
SetProgressCallback(nil, ProgressCallback);
...
end;
end;
Password function PasswordCallback(sender: Pointer; var password: WideString): HRESULT; stdcall;
begin
// call a dialog box ...
password := 'password';
Result := S_OK;
end;
procedure TMainForm.ExtractClick(Sender: TObject);
begin
with CreateInArchive(CLSID_CFormatZip) do begin // using callback
SetPasswordCallback(nil, PasswordCallback);
// or setting password directly
SetPassword('password');
OpenFile('c:\test.zip');
...
end;
end;
Writing archive procedure TMainForm.ExtractAllClick(Sender: TObject);
var
Arch: I7zOutArchive;
begin
Arch := CreateOutArchive(CLSID_CFormat7z);
// add a file
Arch.AddFile('c:\test.bin', 'folder\test.bin');
// add files using willcards and recursive search
Arch.AddFiles('c:\test', 'folder', '*.pas;*.dfm', true);
// add a stream
Arch.AddStream(aStream, soReference, faArchive, CurrentFileTime, CurrentFileTime, 'folder\test.bin', false, false);
// compression level
SetCompressionLevel(Arch, 5);
// compression method if <> LZMA
SevenZipSetCompressionMethod(Arch, m7BZip2);
// add a progress bar ...
Arch.SetProgressCallback(...);
// set a password if necessary
Arch.SetPassword('password');
// Save to file
Arch.SaveToFile('c:\test.zip');
// or a stream
Arch.SaveToStream(aStream);
end;

http://www.progdigy.com/?page_id=13

VC 2008 Feature Pack ::MFC 9.0 - 리본바 (Ribbonbar)

2008 Feature Pack 이라고 거창하게 그러는데,,,사실 뭐 전부터 코드xx,코드xxxx 싸이트에서 꾸준히 공개되고 버전업되고 결국 유료화되면서 유명세를 끌었던 profui ,bcg 라이브러리(별로 최적화되지도 못하고 썩 좋은 평판은 아님,근데 ms에서 이것을 사서 mfc에 구겨넣다니 ㅡㅡ;;;)와 같은 부류의 GUI 라이브러리 중 BCG것을 ms에서 구매해서 낑겨 넣은 것이지만 .....


MFC 9.0 - 리본바 (Ribbonbar)

VC++ 2008에 기능이 보강되어 출시된 MFC 9.0의 대표적인 기능중의 하나가 바로 이 리본바입니다.
이 리본바에는
Visual Manager 라는 기능이 있어 스킨 변경이 쉽게 가능합니다.











위의 그림 처럼 반방향 정렬하는 것도 가능합니다. 아랍권에서 쓰인다고
합니다.

아래의 그림 처럼 Office 2007의 기능을 하는 프로그램과 같이 리본바를 만들수 있습니다.
VC++ 2008만
쓴다면 이것을 사용 할 수 있으니 정말 좋습니다.






















펌:http://myaustin.egloos.com/tag/MFC90/page/1


WIN32 SDK FrameWork 라이브러리

http://www.codeproject.com/KB/winsdk/framework.aspx

Download generics source files - 234.28 KB
Download samples source files - 660.32 KB
Download WCE samples source files - 197.92 KB
Download the tutorials - 1.14 MB

Visual Studio Technical Articles:: Boost for Visual C++ Developers

Visual Studio Technical Articles
Boost for Visual C++ Developers

Beman DawesFounder: Boost.org
May 2004
Summary: Discusses the C++ libraries developed by the Boost community, which add functionality beyond that currently included in the C++ Standard Library. Offers tips to developers for effectively using the Boost libraries, as well as how to contribute to Boost. (11 printed pages)
Contents
IntroductionWhat Is Boost?Boost and the C++ Standard LibraryTypical Boost LibrariesSmart PointersRegular ExpressionsOther Interesting Boost LibrariesUsing Boost with Visual C++Tips for Getting the Most Out of Boost LibrariesContributing to BoostConclusionRelated BooksAppendix: The C++ Standard Library Technical Report (TR)
Introduction
It's no secret that powerful libraries pump up C++ programmer productivity by providing ready-made solutions to common programming problems. Use of modern C++ libraries can shorten development cycles and improve the quality of the finished product.
The Boost community developed C++ libraries to add functionality that starts where the current C++ Standard Library leaves off. The Boost libraries are well known for their usefulness, and several have been accepted by the C++ standards committee for eventual ISO standardization.
The much improved C++ language compliance of Microsoft® Visual C++® .NET 2003 now supports full use of the Boost libraries. This article introduces Boost to Visual C++ developers and looks at some of the individual Boost libraries. It discusses Visual C++ IDE set up for Boost, and gives tips for effective use of the Boost libraries. Finally, the article looks at how you can contribute to Boost.
What Is Boost?
Boost is a Web site (www.boost.org) that provides "free peer-reviewed portable C++ source libraries." Boost isn't one library, but a collection of over 50 libraries that work well together. Library interdependencies are limited to cases where a dependency is justified by the value added. Many users start with only one or two Boost libraries, and then expand use over time.
All of Boost, including code, documentation, and everything else on the Web site is free. Free both in the sense of no charge for use of the libraries, and in the sense of no burdensome licenses, even for commercial use. To be accepted by Boost, libraries go through a formal public review. This peer-review process has resulted in very high-quality libraries. The code is portable, to allow use on multiple compilers and operating systems. Regression tests are run daily on more than a dozen compiler and operating system combinations. Source code is distributed for all libraries, so users can inspect, audit, and modify the code to suit local needs.
Boost can also be viewed as an open-source community. Over a hundred volunteer developers work directly on the libraries. Several thousand programmers worldwide participate in mailing lists, newsgroups, formal library reviews, testing, and all the other activities that support the Boost libraries. Commercial support is also available. There are Japanese language and Chinese language Boost mirror sites run by local Boosters in those countries. Universities and corporations, including Microsoft, help out in various ways, such as hosting mailing lists or contributing compilers.
Boost and the C++ Standard Library
The Boost libraries work well with the C++ Standard Library, and about a dozen of them have been accepted for the upcoming Standard Library Technical Report. That means these libraries will eventually be shipped with most C++ compilers. It's too early to say if or when Microsoft might ship the Technical Report libraries, but the Visual C++ team has been very supportive of Boost and the Library Technical Report, and is actively participating in both efforts. The Boost versions of these libraries are available today, and work very nicely with Visual C++ .NET 2003.
Typical Boost Libraries
We'll look at two Boost libraries that are useful in everyday programming: Smart Pointers and Regular Expressions. Both have been accepted for the Library Technical Report.
We'll also take a brief look at the Type Traits and Template Metaprogramming libraries. These infrastructure tools are especially useful for programmers who develop their own libraries.
Smart Pointers
Memory management in C++ is left up to the programmer. That's great in that it allows critical memory management decisions to be tailored to the application. On the other hand, careless use of heap memory can result in memory leaks and program crashes. Smart pointers are the preferred way in C++ to ensure correct management of dynamic memory allocated by new expressions. Smart pointers are similar to regular pointers, but take care of the details of deleting the object being pointed to when it is no longer needed. The C++ Standard Library already contains std::auto_ptr, a smart pointer with transfer-of-ownership semantics. Boost adds additional smart pointers to handle other common needs, such as shared-ownership semantics.
The Boost shared_ptr class template supplies a shared-ownership smart pointer that can manage dynamically allocated memory in a wide variety of applications, and can be used to intercommunicate with third-party libraries. Unlike std::auto_ptr, shared_ptr works fine with STL containers.
For example, to set up a std::vector of shared_ptr's to a type named Foo, code something like this:
Copy Code
typedef boost::shared_ptr FooPtr;
std::vector foo_vector;
The vector can then be populated like this:
Copy Code
foo_vector.push_back( FooPtr(new Foo(3)) );
foo_vector.push_back( FooPtr(new Foo(2)) );
foo_vector.push_back( FooPtr(new Foo(1)) );
The Shared_ptr Example shown here gives the full code for a sample program:
Copy Code
#include
#include
#include
#include
struct Foo
{
Foo( int _x ) : x(_x) {}
~Foo() { std::cout << "Destructing a Foo with x=" << x << "\n"; }
int x;
/* ... */
};
typedef boost::shared_ptr FooPtr;
struct FooPtrOps
{
bool operator()( const FooPtr & a, const FooPtr & b )
{ return a->x <>x; }
void operator()( const FooPtr & a )
{ std::cout << " " <<>x; }
};
int main()
{
std::vector foo_vector;
foo_vector.push_back( FooPtr(new Foo(3)) );
foo_vector.push_back( FooPtr(new Foo(2)) );
foo_vector.push_back( FooPtr(new Foo(1)) );
std::cout << "Original foo_vector:";
std::for_each( foo_vector.begin(), foo_vector.end(), FooPtrOps() );
std::cout << "\n";
std::sort( foo_vector.begin(), foo_vector.end(), FooPtrOps() );
std::cout << "Sorted foo_vector:";
std::for_each( foo_vector.begin(), foo_vector.end(), FooPtrOps() );
std::cout << "\n";
return 0;
}
The output will be:
Copy Code
Original foo_vector: 3 2 1
Sorted foo_vector: 1 2 3
Destructing a Foo with x=1
Destructing a Foo with x=2
Destructing a Foo with x=3
The library's documentation includes a page on Smart Pointer Programming Techniques that gives many examples of smart pointer usage, including COM and HANDLE examples in a Microsoft® Windows® environment. For any smart pointer used across DLL boundaries, be sure to set the code generation runtime library option (/MD[d]) consistently so that the modules containing both the new and delete share the same runtime heap.
Regular Expressions
The Boost Regular Expression Library, often called regex++, fills a major hole in the C++ Standard Library. Regular expressions perform generalized string pattern matching, and so are nearly essential for string manipulation chores. Here is a simple example from the library's documentation:
Copy Code
bool validate_card_format(const std::string s)
{
static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");
return regex_match(s, e);
}
That regular expression basically says "accept a string if it consists of three sets of four digits followed by a hyphen or a space, and ends with another four digits."
In real applications, regular expressions are often much more complicated. For instance, here is an example for a regular expression that can parse C++ source code and extract class definitions, with class names and specializations identified. This Regular Expression Example comes from several of the library's example programs, which use it to extract class information from C++ program code.
Copy Code
const char* re =
// possibly leading whitespace:
"^[[:space:]]*"
// possible template declaration:
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
// class or struct:
"(classstruct)[[:space:]]*"
// leading declspec macros etc:
"("
"\\<\\w+\\>"
"("
"[[:blank:]]*\\([^)]*\\)"
")?"
"[[:space:]]*"
")*"
// the class name
"(\\<\\w*\\>)[[:space:]]*"
// template specialisation parameters
"(<[^;:{]+>)?[[:space:]]*"
// terminate in { or :
"(\\{:[^;\\{()]*\\{)";
Since the Microsoft® .NET Framework also supplies a regular expression library, should a Visual C++ programmer use it or the Boost library? That probably depends on the application. An application that may someday be ported to other platforms or may be maintained by programmers unfamiliar with .NET might want to use the Boost library. For pure .NET applications, it may make more sense to stick with the Microsoft regular expressions.
Type Traits
The Boost Type Traits library helps programmers manipulate type information at compile time. It has also been accepted for the Library Technical Report. Uses include supporting a wider variety of types in user-written templates, adding compile-time assertions to improve error detection, and enabling optimizations.
Type traits work by providing templates with a value member that will be true or false. For example:
Copy Code
boost::is_integral::value
If the type T is an integral type according to the language rules, that expression will evaluate to true; otherwise it will evaluate to false. Because it is a compile-time expression, it can be used to alter the course of compilation. That allows use in many generic and metaprogramming contexts. The table below lists all the Boost type traits.
Table 1. Type traits
Primary type categories
Secondary type categories
Type properties
Relationships between types
Transformations to type
is_voidis_integralis_floatis_pointeris_referenceis_member_pointeris_arrayis_unionis_classis_enumis_function
is_arithmeticis_fundamentalis_objectis_scalaris_compoundis_member_function_pointer
is_emptyis_constis_volatileis_polymorphicis_podis_abstracthas_trivial_constructorhas_trivial_copyhas_trivial_assignhas_trivial_destructoris_statelesshas_nothrow_constructorhas_nothrow_copyhas_nothrow_assign
is_sameis_convertibleis_base_and_derived
remove_constremove_volatileremove_cvremove_referenceremove_boundsremove_pointeradd_referenceadd_pointeradd_constadd_volatileadd_cv
The Type Traits Example shown below shows type traits used with the BOOST_STATIC_ASSERT macro to check the validity of a template parameter. Because the check is performed at compile time, there is no run-time cost whatsoever.
Copy Code
#include
#include
template<>
void foo( T value)
{
// foo() requires T be integral type
BOOST_STATIC_ASSERT( boost::is_integral::value );
// ... actual computations
}
int main()
{
int i;
float f;
foo( i );
foo( f ); // error! integral type required
return 0;
}
Metaprogramming
Metaprogramming can be loosely defined as "programs that generate programs." Metaprograms run at compile time, tailoring the code that is actually compiled into the final program. Until recently, metaprogramming was an exotic technique known only to a few researchers, but now C++ metaprogramming is becoming more mainstream with libraries available to handle the details. Boost's metaprogramming libraries provide both preprocessor metaprogramming and template metaprogramming facilities.
The Boost Template Metaprogramming Library (MPL) provides a wealth of operations on types, including control flow, containers, iterators, and algorithms. Here is an example, adapted from the MPL documentation:
Copy Code
template<>
class auto_size_example
: private mpl::if_< sizeof(T) <= sizeof(double)
, stack_implementation
, heap_implementation
>::type
{
// ...
};
When an auto_size_example template is instantiated at compile time, MPL's if_ will determine whether to inherit from stack_implementation or heap_implementation depending on the size of the template parameter T. The net result is an optimization that would be difficult to perform otherwise.
Other Interesting Boost Libraries
Some of the Boost libraries address specific problem domains that not every programmer cares about. For example, the Boost Spirit Library is of interest only to those who need a parser generator, at least at first glance. But Spirit allows extended BNF grammars to be expressed directly in C++, and as such is a considerable intellectual achievement worth studying just for the joy of viewing a world-class design. The Boost Graph Library is another major effort, and a great example of how generic programming concepts can be applied.
In addition to their usefulness, Boost is full of libraries large and small worth studying as design cases. One of the unanticipated benefits of Boost is that it has brought together experienced software developers and innovative academic researchers. That combination has resulted in library designs that are practical yet creative. It isn't uncommon for programmers to read the Boost mailing lists or newsgroups just to watch new Boost library designs evolve.
Using Boost with Visual C++
The first step is to upgrade to Visual C++ .NET 2003. Earlier Visual C++ versions didn't support partial specialization and other template features required by many Boost libraries, making use difficult.
Installing Boost begins by downloading and unzipping the distribution file. A Boost directory tree will be created exactly equivalent to the Web site and containing all files, including sources and documentation.
Many Boost libraries are entirely implemented in their headers, so the only preparation for use beyond downloading and unzipping is to add the Boost root directory to the list of include paths. In the Visual C++ IDE, click Tools Options... Projects VC++ directories. Then in Show Directories for, select Include files and add the path to the Boost root directory.
At that point, you should be ready to use the header-only Boost libraries. You can build and run the Shared_ptr Example shown earlier to verify your set up is complete.
Some of the Boost code does live in object libraries, and so requires a preparatory build. The Boost distribution includes bjam, a powerful and portable make replacement. The scripts (called Jamfiles) to build Boost object libraries are supplied. If Visual C++ is the only compiler you care about, some of the Boost libraries supply make files to build Visual C++ object libraries directly. Boost object library build and install procedures are a weak point at the moment, so expect a few bumps on the road.
Tips for Getting the Most Out of Boost Libraries
Boost libraries develop over time. Sometimes interfaces change, and when a better idea surfaces, an entire library may undergo extensive changes. The older libraries tend to be quite stable, but even so are subject to some change if they become subject to ISO standardization. Rather than take a chance on breaking your existing code, freeze the Boost version your project uses, and only upgrade to a new Boost release when your project is at a point in its lifecycle where a bit of change won't be a problem. If you need a fix for a specific problem, check the Boost CVS to see if a specific fix is available. Because the entire Boost development process is public, you can also ask Boost developers for help with specific problems. There are several mailing lists for support, and these can also be accessed by Web newsgroups. See the Boost Web site for details.
Contributing to Boost
Boost depends on volunteer programmers contributing time and effort; there is no paid staff and the budget is exactly zero. There are a lot of different ways you can contribute to Boost. The most obvious is to contribute a library. But other forms of contribution are equally important.
To be accepted by Boost, libraries go through a formal review process. Anyone can contribute a formal review, and that's a great way to help Boost. Some experienced Boost users help by answering questions from new uses on the Boost-Users mailing list and newsgroup. Some of the larger Boost libraries have their own mailing lists and teams of developers. The best way to get started is to read the main developers mailing list for a while to see how the Boost process works.
Conclusion
The much improved C++ language compliance of Visual C++ .NET 2003 allows full use of the Boost libraries by Visual C++ developers. These community-developed libraries cover a spectrum of needs, ranging from everyday to very specialized. They can be huge productivity boosters, they have interesting designs, and the Boost libraries are absolutely free.
Related Books
Microsoft Visual C++ .Net 2003 Kick Start by Kate Gregory
C++ Templates: The Complete Guide by David Vandevoorde and Nicolai M. Josuttis
The Boost Graph Library: User Guide and Reference by Jeremy G Siek
Appendix: The C++ Standard Library Technical Report (TR)
The C++ Standard Library Technical Report is the ISO C++ Committee's way of gently adding new features to the C++ Standard Library. The additions are "non-normative," meaning that vendors don't have to supply them, although most will. A TR can move through the ISO standardization process more rapidly than a full update to the standard.
Technical Reports often become part of the official standard at a later date. Think of them as 0.9 versions of future releases.
Although details of the Library TR are still being finalized, it looks like most components will be in namespace TR1. When the TR libraries later become full-fledged parts of the Standard Library, they will move to namespace std. This allows the libraries to be changed without breaking existing code. User experience with the TR will determine if such changes are necessary.
A list of libraries that will be in the Library TR is available on the ISO C++ public Web site.

About the author
Beman Dawes is a software developer from Virginia in the United States and the founder of boost.org. He is the author of the StreetQuick® geographic atlas library used by digital map publishers to help people get really, really, lost. Beman has been a voting member of the ANSI/ISO C++ Standards Committee since 1992, and chaired the Library Working Group for five years.
© 2009 Microsoft Corporation. All rights reserved. Terms of Use Trademarks Privacy Statement

Visual C 에서 CRT와 MFC 라이브러리가 잘못된 순서로 링크되면 LNK2005

CRT(C 런타임) 라이브러리와 MFC(Microsoft Foundation Class) 라이브러리가 잘못된 순서로 링크되면 다음 LNK2005 오류 중 하나가 발생할 수 있습니다.
nafxcwd.lib(afxmem.obj) : 오류 LNK2005:"void * __cdecl operator new(unsigned int)"(??2@YAPAXI@Z)이(가)LIBCMTD.lib(new.obj)에 이미 정의되어 있습니다.
nafxcwd.lib(afxmem.obj) : 오류 LNK2005:"void __cdecl operator delete(void *)"(??3@YAXPAX@Z)이(가)LIBCMTD.lib(dbgnew.obj)에 이미 정의되어 있습니다.
nafxcwd.lib(afxmem.obj) : 오류 LNK2005:"void * __cdecl operator new(unsigned int,int,char const *,int)"(??2@YAPAXIHPBDH@Z)이(가) LIBCMTD.lib(dbgnew.obj)에 이미 정의되어 있습니다.
mfcs40d.lib(dllmodul.obj): 오류 LNK2005: _DllMain@12이(가)MSVCRTD.LIB (dllmain.obj)에 이미 정의되어 있습니다.
mfcs42d.lib(dllmodul.obj): 오류 LNK2005: _DllMain@12이(가)msvcrtd.lib(dllmain.obj)에 이미 정의되어 있습니다.
CRT 라이브러리는 new, delete 및 DllMain 함수에 대해 약한 외부 링크를 사용합니다. MFC 라이브러리에는 new, delete 및 DllMain 함수도 포함되어 있습니다. 이러한 함수가 제대로 작동하려면 CRT 라이브러리가 링크되기 전에 MFC 라이브러리가 링크되어야 합니다.
이 문제를 해결할 수 있는 방법에는 두 가지가 있습니다. 첫 번째 해결 방법은 올바른 순서로 라이브러리를 링크하도록 링커를 설정하는 것입니다. 두 번째 해결 방법은 문제를 일으키는 모듈을 찾아 해결하는 것입니다. 참고 다음 단계는 Visual C++ 6.0을 기반으로 합니다.

해결 방법 1: 올바른 순서로 라이브러리를 링크하도록 링커 설정
Project 메뉴에서 Settings를 누릅니다.
Project Settings 대화 상자의 Settings For 뷰에서 링크 오류가 발생하는 프로젝트 구성을 선택합니다.
Link 탭의 Category 콤보 상자에서 Input을 선택합니다.
Ignore libraries 상자에 라이브러리 이름(예: Nafxcwd.lib;Libcmtd.lib)을 삽입합니다. 참고 링커 명령줄은 /NOD:과 동일합니다.
Object/library modules 상자에 라이브러리 이름을 삽입합니다. 이 이름은 반드시 해당 행의 처음 두 라이브러리와 같은 순서대로 나열되어야 합니다(예: Nafxcwd.lib Libcmtd.lib).Visual C++ .NET에서 이 옵션을 설정하려면 "Visual C++ 프로젝트 속성 설정" 온라인 도움말 항목을 참조하십시오.

해결 방법 2: 문제가 있는 모듈을 찾아 해결현재 라이브러리 링크 순서를 보려면 다음과 같이 하십시오.
Project 메뉴에서 Settings를 누릅니다.
Project Settings 대화 상자의 Settings For 뷰에서 링크 오류가 발생하는 프로젝트 구성을 선택합니다.
Link 탭의 Project Options 상자에 /verbose:lib를 입력합니다.
프로젝트를 다시 빌드합니다. 링크하는 과정에서 출력 창에 라이브러리가 표시됩니다.
MFC 라이브러리를 사용할 때는 CRT 라이브러리가 링크되기 전에 MFC 라이브러리가 링크되도록 해야 합니다. 이렇게 하려면 프로젝트에 있는 모든 파일이 직접(#include ) 또는 간접(#include )적으로 먼저 Msdev\Mfc\Include\Afx.h를 포함하도록 합니다. Afx.h 포함 파일은 #pragma 주석(lib,"libname") 지시어를 사용하여 라이브러리의 순서를 올바르게 조정합니다. 원본 파일 확장명이 .c이거나 파일 확장명이 .cpp이지만 MFC를 사용하지 않는 경우 모듈 맨 위에 작은 헤더 파일(Forcelib.h)을 만들어 포함시킬 수 있습니다. 이 새로운 헤더가 라이브러리 검색 순서를 올바르게 합니다. Visual C++에는 이 헤더 파일이 들어 있지 않습니다. 이 파일을 만들려면 다음과 같이 하십시오.
Msdev\Mfc\Include\Afx.h를 엽니다.
#ifndef _AFX_NOFORCE_LIBS와 #endif //!_AFX_NOFORCE_LIBS 사이의 행을 선택합니다.
선택 영역을 Windows 클립보드로 복사합니다.
새 텍스트 파일을 만듭니다.
클립보드 내용을 새 파일에 붙여 넣습니다.
파일을 Msdev\Mfc\Include\Forcelib.h로 저장합니다.

Visual C++ .NET에서 문제를 재현하는 방법
Microsoft Visual Studio .NET을 시작합니다.
파일 메뉴에서 새로 만들기를 가리킨 다음 프로젝트를 누릅니다.
프로젝트 형식에서 Visual C++ 프로젝트를 누른 다음 템플릿에서 MFC 응용 프로그램을 누릅니다.
이름 텍스트 상자에 Q148652를 입력합니다.
위치 텍스트 상자에 C:\Test를 입력한 다음 확인을 누릅니다.
MFC 응용 프로그램 마법사 대화 상자에서 응용 프로그램 종류를 누릅니다.
응용 프로그램 종류 아래에서 대화 상자 기반을 누른 다음 MFC 사용 아래에서 정적 라이브러리에서 MFC 사용을 누릅니다.
마침을 누릅니다.
솔루션 탐색기의 소스 파일에서 세 가지 .cpp 파일을 모두 선택합니다.
선택한 세 가지 파일을 마우스 오른쪽 단추로 누른 다음 제거를 누릅니다.
소스 파일을 마우스 오른쪽 단추로 누르고 추가를 가리킨 다음 새 항목 추가를 누릅니다.
템플릿 아래에서 C++ 파일을 누릅니다. 이름 텍스트 상자에 Aa를 입력합니다. 열기를 누릅니다.
Aa.cpp 파일에 다음 코드를 붙여 넣습니다.
int test(){new int; return 1;}
소스 파일을 마우스 오른쪽 단추로 누르고 추가를 가리킨 다음 기존 항목 추가를 누릅니다.
다음 파일을 선택합니다.
Q148652.cpp
Q148652Dlg.cpp
stdafx.cpp
열기를 누릅니다.
15단계에서 선택한 파일이 소스 파일 아래에 나타납니다.
소스 파일 아래에서 네 가지 .cpp 파일을 모두 선택합니다.
선택한 네 가지 .cpp 파일을 마우스 오른쪽 단추로 누른 다음 속성을 누릅니다.
구성 속성을 확장한 다음 C/C++를 확장합니다.
미리 컴파일된 헤더를 누릅니다.
미리 컴파일된 헤더 만들기/사용 속성을 미리 컴파일된 헤더 사용 안 함으로 설정합니다. 확인을 누릅니다.
빌드 메뉴에서 솔루션 다시 빌드를 누릅니다.Microsoft 제품 관련 기술 전문가들과 온라인으로 정보를 교환하시려면 Microsoft 뉴스 그룹 (http://support.microsoft.com/newsgroups/default.aspx) 에 참여하시기 바랍니다.

본 문서의 정보는 다음의 제품에 적용됩니다.
Microsoft Visual C++ 4.0 Standard Edition
Microsoft Visual C++ 4.1 Subscription
Microsoft Visual C++ 5.0 Enterprise Edition
Microsoft Visual C++ 6.0 Enterprise Edition
Microsoft Visual C++ 5.0 Professional Edition
Microsoft Visual C++ 6.0 Professional Edition
Microsoft Visual C++, 32-bit Learning Edition 6.0
Microsoft Visual C++ .NET 2002 Standard Edition
Microsoft Visual C++ .NET 2003 Standard Edition

http://support.microsoft.com/kb/148652

거꾸로 가는 MicroSoft™ 의 운영체제

펌)) http://aerosmith.tistory.com


거꾸로 가는 MicroSoft™ 의 운영체제



MS 의 운영체제 시리즈의 최대 단점은 하드웨어에 대한 드라이버(소프트웨어)지원이다.

과거의 Linux 는 MS 가 내놓은 운영체제들보다 하드웨어에 대한 드라이버 지원이 매우 약했고 사용자들은 Linux 용 하드웨어 드라이버를 구하지 못해 결국 Linux 의 사용을 포기하는 상황에까지 갔었지만, 최근에 MS 가 보여주는 행태는 과거 Linux 에서처럼 하드웨어에 대한 드라이버 지원이 매우 미미하다. 즉 상황이 역전된 것이다.

Linux VS MS 를 놓고 보자면 구형 하드웨어가 장착된 PC 의 경우 Linux 가 MS 의 새로운 운영체제들보다 하드웨어적인 지원이 훨씬 낫다.

최근 MS 는 Vista 에 이어 Windows 7 를 시장에 내놓기위해 안간힘을 쓰는듯하다. 그러나 과연 Windows Vista 부터 얼만큼의 효율성이 있을까에 대한 필자의 생각은 회의적이다.

충분히 쓸수있는 하드웨어임에도 불구하고 운영체제가 바뀌었다고해서 쓰지못한다면, 세상에 낭비도 이런 낭비가 없다. 불행히도 MS 의 운영체제들은 그 서로간에 하드웨어 드라이버가 호환되지않는다. 즉 Windows XP 와 Windows Vista 와 Windows Server 2008 시리즈와 Windows 7 은 동일한 하드웨어에 대해 각각의 드라이버가 호환되지않는다는 뜻이다.

ATi 의 Radeon 7000 의 경우 Windows Server 2008 전용 드라이버가 존재하지않고 XP 드라이버를 인스톨했다가는 Windows ME 시절에서나 볼 수 있었던 Blue Screen 을 볼 수 있다.

반면 Linux 의 경우 빌드 버전이 올라가도 드라이버는 거의 동일하기때문에 오랜 세월동안 수많은 하드웨어들을 지원하게 된다. 특별히 초특급 구형 하드웨어이거나 초특급 레어 하드웨어가 아닌 이상은 Linux 가 지원하지않는 드라이버는 거의 없다고해도 과언이 아니다. 게다가 새로운 하드웨어에 대한 지원도 꾸준하다는 점은 필자가 Linux 를 사용하지않을수없게 만드는 주요 이유가 된다.

MS 가 내놓는 운영체제들처럼 운영체제가 바뀌었다고해서 충분히 그 기능을 하고있는 하드웨어를 드라이버가 없어서 더이상 쓰지못한다는 것은 정말 어처구니가 없는 상황이다 ! 더구나 MS 가 내놓는 운영체제의 수명은 10년을 채우지 않으며 새로운 운영체제를 발표하면 그 이전의 운영체제에 대한 지원은 길어보야 4년 정도다. 결국 MS 의 운영체제를 사용하면 길어야 14년도 채 안되는 세월동안만 하드웨어에 대한 소프트웨어가 지원될 뿐이라는 거다.

결국 MS 는 하드웨어적으로 보자면, 시대를 역행하는 운영체제를 내놓고 있는 셈이고, 사용자로 하여금 운영체제가 바뀔때마다 하드웨어를 교체하게 만듦으로서 사용자들에게 금전적 손실을 안겨주며, 이러한 MS 의 태도에 필자는 분노를 느끼지않을수 없다 !!

MS 가 던져주는 운영체제가 바뀌었다고해서 멀쩡한 하드웨어를 시스템에서 제거해야만 하다니... 정말이지 낭비도 이런 낭비가 없다.

출처: http://aerosmith.tistory.com

펌끝))


--------------------------------------------------------------------------------



Linux,Unix 소스따다가 DOS 만들고,X-Window 와 Mac OS 본따서 M$ Window 만들고 기술 가져다가 O.S 업글하고 멀티태스킹이다 뭐다 업계에 이미 나와있던 기술을 마치 M$에서 개발한 새로운 기술처럼 발표하고 드라이버,하드웨어,OEM 시장을 앞서 상업적인 마케팅으로 주도하고 우려먹기 시작..
O.S 도 포장만 바꿔서 완전 새로운 것처럼 내놓고 우려먹고 우려먹고 그게 그거를 한 20년...넷스케이프 잡아먹고,리얼플레이어 잡아먹고,,,,,
VM이다 XPM이다 뭐다 업계에서 유행탈만한것 O.S에 꾸겨넣는걸 보면 결국 아이템도 다 떨어져...

이제 바탕화면 아이콘만 새롭게 그려놓고 새로운 O.S요! 하고 내놓을 판국에..

이제 완전 '새' 될때만 기다려야 할듯.....

MS의 것은 오픈된 소스도 없다.얼마전 오픈소스인 Zlib(압축라이브러리) 를 MS-Office 제품군에서 불법으로 사용한 흔적이 발견되엇다 한다.
아마 오픈하면 안될 난처한 이유가 분명 따로 있을 것이다.

기술발전을 앞서기 보다는 이미 오픈기술과 오픈소스 계를 엿보다가 뜰거같은 기술을 가로채와 즉시 상업화하고 특허화하여 사유화 시키는 최고의 경영기술!

십여년전 부터 듣던 얘기가 있다..예전부터 혹자들은 말한다.
M$때문에 컴퓨팅기술이 10년은 퇴보했고 발전이 저지되고 있다고 .....



그런데 왜 도대체 아직도,Vista 계열이후 버전에서 저해상도,그래픽인식오류등의 치명적인 보드와 그래픽카드 I/O 와 연관된 ATIKMDAG 문제,(즉 Windows Vista Display Driver Model (WDDM) driver 에 대해 오류가 있음이 분명) 를 해결할 생각을 안하나 모르겠다..

관련기사: http://blog.hanafos.com/yeamaec/512

VC 에서 EXE크기 줄이면서 MFC90,MSVCRxx MSVCP DLL 포함 안하는 법



VC++ 프로젝트는 간단하지
않은 프로젝트들 거의 대부분이 SDK 가 아닌 MFC 프로젝트들로 이루어져 개발되고
있다.


그러나 개발할때는 편하게
쓰지만,막상 배포시 너무 큰 크기라든가 MFC DLL들을 함께 배포해야 하는등의
부수적인 문제가 수반된다.


물론 이렇게 이런 부분까지
민감하지 않는 사람들이 대부분이다.
(회사차원 프로젝트에서는 더더욱 이런 세심한
관심은 필요없다)


하지만,작은 유틸리티,SDK
(WIN32 API,이젠 뒤늦게 나마 O.S 시장에서 MS의 윈도우계열이 거의 꼴지로
64bit 대열에 합류했으므로 WIN32라는 말도 조만간 바뀌겠지)로는 짤수없고 다양한
공용컨트롤등을 사용하려면 MFC 클래스나 IE,OFFICE등의 컨트롤을 써야만 할것이다.


기업용은 대다수 기능과
안정성을 중시로 크게 오류가 나지않는 한은 제품의 형태나 크기등은 크게 문제되지
않는다.
하지만 PC에 설치되는 개인용 유틸리티 성격의 프로그램은 안정성은 물론
그 크기와 속도등의 최적화도 그 프로그램의 기능과 스케일에 맞게 성능을 판단하는
한가지 근거자료가 될것이다.


예를 들어,파일을 복사하고
이동하는 자동이름 변경마법사 등의 유틸리티가 200KB 정도내외이면 가능한 기능인데
무려 1-2MB 를 상회한다면 무엇인가 큰 낭비요소가 작용하고 있음을 나타낸다.


따라서 다음과 같은 고민에
빠져들수 있다.((물론 대부분 개발자가 안그러지만))


최신 컨트롤을 쓰기 위해서는
SDK API 로는 코딩의 한계와 어려움이 있다.따라서 분명 MFC나 ATL등 고급화된 함수나
클래스들을 써서 이쁘고 다양한 컨트롤이나 메인화면을 구현해야만 한다.


MFC를 쓰되 MFC DLL을 함께
배포하지 않는 방법은 없을까?
물론 '공유DLL에서 MFC 사용' 을 하면 MFC로 개발해도
상관없다.


단,VS6,VS2003,VS2005,VS2008등
무엇을 썼느냐에 따라 재배포 패키지를 함께 설치해야만 한다.
현재 시점에서
VS2008에서 개발했을 경우 무려 4MB가까이 되는 용량이 될수있다.(9.0.21022.8 버전은
MFC90.DLL이 약 1MB를 넘지만 9.0.30729.1 버전은 이미 4MB 에 가깝다) 그러나
내 본 프로그램의 크기는 작을 것이다. 그리고 프로그램이 하는 기능도 사실 몇줄
되지 않고 별거 아닐것인데 단지 MFC 프로젝트로 작성했다는 이유만으로 무려 배보다
배꼽이 더 크게 되버린 경우이다.


이럴경우, 내 프로그램을
더이상 '공유DLL에서 MFC 사용'으로 만들면 안되겠다. 그렇다면,SDK로 코딩을 바꿔야
하나? 이것은 전혀 불가능할지도 모를 쓸데없는 시간낭비 일 것이다 .. 물론 가능은
하겟지만,,, 불필요한...
예를 들어,CWnd 형으로 상속받아 작성한 내 커스텀 컨트롤(탭,리스트
및 다양한 것들) 의 소스코드를 모두 SDK에 맞도록 리펙토링 해야할것이다.


어려운방법인 셈이고 다른
최신형의 컨트롤을 쓸때마다 이런짓을 해야할지도 모른다.


MFC를 쓰면서 '공유DLL에서
MFC 사용' 을 하지않고 좀더 쉬운방법은 없을까??


우선,'정적 라이브러리에서
MFC 사용'을 선택하면 MFC 공용 DLL들이 필요하지 않게 된다. 하지만 Dependency
Tool 로 의존성 있는 DLL이 무엇인지 MFC,MSVCR90,MSVCP90(VS2008의 경우 90,그리고
VS2005는 71등,버전별로 달라진다.) 잘 봐야한다.


그림에서) 물론 UICtrlsd.dll
은 Debug모드이지만 (Debug모드에서는 이방법대로 빌드하지 않고 기존처럼 공유DLL
모드로 빌드한것이기 때문에) MFC DLL이 의존되어 있다.(뒤쪽에 나중에 빌드한 UICtrls.dll
그림과 비교해보자)





하지만,이또한
다소 문제가 있다. MFC 공유 DLL을 안쓰는대신에 내 코드크기가 그만큼 Statictics
되어 삽입되어 지므로 훨씬 더 커진다.


여러차례에 걸쳐 100% 까지
검증된 법은 아니지만 방금 전 데모 프로그램으로 확인완료했다. 즉 1차로 검증해본
결과 100% 실행되고 있음이 확인되었다.





위
그림은 이렇게 완전히 MFC 공유 DLL 사용하지 않도록 '정적
라이브러리에서 MFC 사용' 모드로 빌드한 결과이다.MFC 로
빌드한 것 치고는 일단은 크기들이 그렇게 많이 크지않다,EXE 크기는 현재 372KB
(381,440 바이트) 이므로 여기에 사용자 기능을 덕지덕지 붙인다면 아마 1MB 안팎의
안정된(?) 크기로 만들수 있을 것이다. UltraEdit 10.5 버전이 크기가 무려 9.06MB
(9,507,600 바이트) 가 넘는 엄청난 크기이다. 그다지 멀지 않은 예전 같으면 시스템
메모리카드 9개 크기를 훌쩍넘다니... 예전에는 어떻게 해서든 1KB 라도 줄여보려고
나온 기술들이 진일보해 주도했던 반면, 요새는 최적화된 기법없이 모두 하드웨어적
사양에만 의존하며 하드웨어적으로도 소프트웨어적으로도 너무 낭비하고 안일하게
방대해지는 듯한 현실이 씁쓸할 뿐이다.


먼훗날 누군가 최선형 우주선을
타고 우주여행을 갔다가 의문의 사고로 돌아오지 못했다.본부에서는 블랙박스를 회수해
원인을 분석한 결과,우주선 시스템에 문제가 발생해 관련 응용프로그램을 다시 설치하는
도중 너무 방대한 크기에 설치시간이 너무 지체되어 운석층을 미쳐 피하지 못했다
한다..


솔직히 윈도우즈 O.S 크기만
무려 2GB가 훌쩍넘는다. 그나마 리눅스는 CD한장에(670MB) 딱들어간다.
예전에는
디스켓 한두장에 다 집어넣으려고 총력을 기울였던 말그대로 마이크로 기술이 대세였지만
어느새,좀 잘살게 되고 넉넉한 탓인지 너무 흥정망청 자원을 쓰는게 아닌가 생각이
든다.


1)먼저 Panorama.exe 는
MFC 클래스를 이용한 실행파일 프로젝트이다.


2)UICtrls.dll 은 MFC 컨트롤
클래스를 커스텀화한 다양한 사용자 클래스들이 포함되어 있다.


3)Sknsys.dll 은 Win32 API
로만 구성된 순수한 SDK DLL 이다.


1)의 프로젝트 구성은 다음과
같다.


MFC 사용:정적
라이브러리에서 MFC 사용
런타임 라이브러리: 다중 스레드(/MT)


2)의 프로젝트 구성은 다음과
같다.


원래는,공유DLL에서
MFC 사용이며 Extension DLL로 생성한 프로젝트이다.


정적 라이브러리에서
MFC 사용
런타임 라이브러리: 다중 스레드(/MT)



3)의 프로젝트
구성은 다음과 같다.


원래는,표준
Windows 라이브러리 사용으로 생성한 프로젝트이다.


정적 라이브러리에서
MFC 사용
런타임 라이브러리: 다중 스레드(/MT)
추가종속성에
다음을 포함하였다.
(링크에러가 나면 찾아서 추가해줘야함)
Comctl32.lib
Gdi32.lib User32.lib Ole32.lib olepro32.lib



'정적 라이브러리에서 MFC
사용' 하면 1) EXE 크기가 커지므로 최대한
리소스(이미지,아이콘)를 파일로 Export해서
런타임시 읽도록 코드수정해야 한다.


또한,const 형식으로 소스내
선언한 고정값의 "스트링"도 크기에 한몫한다.


이를 없애서 별도의 리소스
DLL에 빼놓거나 INI등 환경설정파일로 Export해야 한다.


또한,2)번의 DLL은 내부적으로
MFC 클래스를 쓰고 있는데,이때 1)의 EXE 메인 프로그램만 '정적 라이브러리에서
MFC 사용'으로 변경해서 빌드했다고 해도 2)번의 UICtrls.dll을 로드하는 과정에서
MFC 공용 DLL을 찾게 된다.


따라서,여기서 2)번처럼
EXE 자신이 불러쓰는 DLL 파일의 프로젝트도 바꿔줘야 한다. 한데 ,위의 2)의 설정으로
아무리 설정을 바꿔서 컴파일해도 Dependency Tool 로 확인 해보면 MFC 계열 공유
DLL이 그대로 의존된 채로 변함없고 잘 바뀌지가 않을 것이다.


정적링크 = /MT, 공유링크
= /MD



이런경우에 대해 찾던중,꼬박
반나절만에,,,해결책을 발견!


이런경우,프로젝트의 소스코드를
약간 바꿔준다.


예를들어 UiCtrls.dll에
포함된 한가지 클래스중에는 다음과 같은것이있었다.



class AFX_EXT_CLASS CResizingDialog
: public CDialog


그리고 UICtrls.cpp 프로젝트
메인 cpp 파일 에는 다음과 같이 되어있을 것이다.


#include "stdafx.h"
#include <afxdllx.h >


static AFX_EXTENSION_MODULE
UIctrlsDLL = { NULL, NULL };



extern "C" int
APIENTRY


DllMain(HINSTANCE hInstance,
DWORD dwReason, LPVOID lpReserved)


{


//
lpReserved를 사용하는 경우 다음을 제거하십시오.


UNREFERENCED_PARAMETER(lpReserved);



if
(dwReason == DLL_PROCESS_ATTACH)


{


TRACE0("UIctrls.DLL
초기화!\n");



//
확장 DLL을 한 번만 초기화합니다.


if
(!AfxInitExtensionModule(UIctrlsDLL, hInstance))


return
0;



//
이 DLL을 리소스 체인에 삽입합니다.


//
참고: 이 확장 DLL이 MFC 응용 프로그램이


//
아닌 ActiveX 컨트롤 같은 MFC 기본 DLL에


//
의해 명시적으로 링크되어 있는 경우에는


//
DllMain에서 이 줄을 제거하고, 제거한 줄은 이 확장 DLL에서


//
내보낸 별도의 함수에 추가합니다.


//
그런 다음 이 확장 DLL을 사용하는 기본 DLL은


//
해당 함수를 명시적으로 호출하여 이 확장 DLL을


//
초기화해야 합니다. 그렇지 않으면, CDynLinkLibrary 개체가


//
확장 DLL의 리소스 체인에 추가되지 않으므로


//
심각한 문제가 발생합니다.



new
CDynLinkLibrary(UIctrlsDLL);



}


else
if (dwReason == DLL_PROCESS_DETACH)


{


TRACE0("UIctrls.DLL
종료!\n");



//
소멸자가 호출되기 전에 라이브러리를 종료합니다.


AfxTermExtensionModule(UIctrlsDLL);


}


return
1; // 확인


}


위를 각각 다음과 같이 수정한다.
#ifdef
UICTRLS_EXPORTS


#define
UICTRLS_API __declspec(dllexport)


#else

#define
UICTRLS_API __declspec(dllimport)


#endif


class UICTRLS_API CResizingDialog
: public CDialog


물론 프로젝트 전처리기에는
다음처럼 UICTRLS_EXPORTS 이 추가되어있어야한다.
또한 _AFXEXT가(_AFXDLL도)
있으면 지우고 _USRDLL을 선언해라.


WIN32;_WINDOWS;NDEBUG;_USRDLL;UICTRLS_EXPORTS


*_USRDLL 선언시 AfxGetResourceHandle(); 함수 도움말 내용을 꼭 확인하라.



DllMain은 중복에러가 날것이다.
그러므로 #if 0 ~~ #endif 로 주석처리하든가 소스에서 제거해라!


UICtrls.def 는 아직 수정하지
않아도 된다.



EXE 소스에서 CResizingDialog
클래스를 불러다 쓸수 있게 된다.


물론,두 프로젝트 모두 MFC
공유 DLL이 필요하지 않다.


크기가 상당히 작아졌다.



2)의 경우는 이미 MFC Extension
DLL 로 선언한 프로젝트를 정적으로 바꾸는 경우이고 3)의 경우는 SDK WIN API DLL
로 선언한 프로젝트를 나중에 MFC 가능하게 바꾸는 경우이다.



UICtrls.dll 의 stdafx.h
는 다음과 같다.


// stdafx.h : 자주 사용하지만
자주 변경되지는 않는


// 표준 시스템 포함 파일
및 프로젝트 관련 포함 파일이


// 들어 있는 포함 파일입니다.


#pragma once


#ifndef VC_EXTRALEAN

#define VC_EXTRALEAN //
거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.


#endif


// 아래 지정된 플랫폼에
우선하는 플랫폼을 대상으로 해야 한다면 다음 정의를 수정하십시오.


// 다른 플랫폼에 사용되는
해당 값의 최신 정보는 MSDN을 참조하십시오.


#ifndef WINVER //
Windows 95 및 Windows NT 4 이상에서만 기능을 사용할 수 있습니다.


#define WINVER 0x0400 //
이 값을 Windows 98 및 Windows 2000 이상을 대상으로 하는 데 적합한 값으로 변경하십시오.


#endif


#ifndef _WIN32_WINNT //
Windows NT 4 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_WINNT 0x0400 //
이 값을 Windows 2000 이상을 대상으로 하는 데 적합한 값으로 변경하십시오.


#endif


#ifndef _WIN32_WINDOWS //
Windows 98 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_WINDOWS
0x0410 // 이 값을 Windows Me 이상을 대상으로 하는 데 적합한 값으로 변경하십시오.


#endif


#ifndef _WIN32_IE //
IE 4.0 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_IE 0x0400 //
이 값을 IE 5.0 이상을 대상으로 하는 데 적합한 값으로 변경하십시오.


#endif


#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS //
일부 CString 생성자는 명시적으로 선언됩니다.



#include <afxwin.h >// MFC 핵심 및 표준 구성 요소입니다.

#include <afxext.h >// MFC 확장입니다.


#ifndef _AFX_NO_OLE_SUPPORT

#include <afxole.h >
// MFC OLE 클래스입니다.


#include <afxodlgs.h >
// MFC OLE 대화 상자 클래스입니다.


#include <afxdisp.h >
// MFC 자동화 클래스입니다.


#endif // _AFX_NO_OLE_SUPPORT


#ifndef _AFX_NO_DB_SUPPORT

#include <afxdb.h >//
MFC ODBC 데이터베이스 클래스입니다.


#endif // _AFX_NO_DB_SUPPORT


#ifndef _AFX_NO_DAO_SUPPORT

#include <afxdao.h >//
MFC DAO 데이터베이스 클래스입니다.


#endif // _AFX_NO_DAO_SUPPORT


#include <afxdtctl.h >//
Internet Explorer 4의 공용 컨트롤에 대한 MFC 지원입니다.


#ifndef _AFX_NO_AFXCMN_SUPPORT

#include <afxcmn.h >//
Windows 공용 컨트롤에 대한 MFC 지원입니다.


#endif // _AFX_NO_AFXCMN_SUPPORT


SknSys.DLL 의 Stdafx.h
는 다음과 같다.


// stdafx.h : 자주 사용하지만
자주 변경되지는 않는


// 표준 시스템 포함 파일
및 프로젝트 관련 포함 파일이


// 들어 있는 포함 파일입니다.


//



#pragma once


// 아래 지정된 플랫폼에
우선하는 플랫폼을 대상으로 하는 경우 다음 정의를 수정하십시오.


// 다른 플랫폼에 사용되는
해당 값의 최신 정보는 MSDN을 참조하십시오.


#ifndef WINVER //
Windows XP 이상에서만 기능을 사용할 수 있습니다.


#define WINVER 0x0501 //
다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.


#endif


#ifndef _WIN32_WINNT //
Windows XP 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_WINNT 0x0501 //
다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.


#endif


#ifndef _WIN32_WINDOWS //
Windows 98 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_WINDOWS
0x0410 // Windows Me 이상에 맞도록 적합한 값으로 변경해 주십시오.


#endif



#ifndef _WIN32_IE //
IE 6.0 이상에서만 기능을 사용할 수 있습니다.


#define _WIN32_IE 0x0600 //
다른 버전의 IE에 맞도록 적합한 값으로 변경해 주십시오.


#endif



#define WIN32_LEAN_AND_MEAN //
거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.


// Windows 헤더 파일:


#include <windows.h >

#include <windowsx.h >


// C RunTime Header Files

#include <stdlib.h >

#include <malloc.h >

#include <memory.h >

#include <tchar.h >

#include <commdlg.h >

#include <winuser.h >

#include <shellapi.h >

#include <shlobj.h >

#include <io.h >

#include <stdio.h >

#include <fcntl.h >

#include <sys>

#include <commctrl.h >


#define _CRT_SECURE_NO_WARNINGS


// Local Header Files

//#include "resource.h"


void LineLog(LPCSTR pszFormat,...);


// TODO: 프로그램에 필요한
추가 헤더는 여기에서 참조합니다.



서로 틀림을 알수있다.


Dependency Walker 로 의존성
검사한 화면







이 것은,필자 본인이 백업겸
올려놓은 개인적인 견해이므로 실험내용에 추가 검증이 있을때까지 오차가 있을수
있음.(예를 들어 CResizingDialog를 UICtrls.DLL을 EXE에서 불러오게끔 하기위해
변수 선언만 했을 뿐, 이것을 CDialog 형태로 DoModal() 등이나 Create() 등으로
직접 호출을 해보지는 않았다)


단,주의해야 할것은 HINSTANCE hInst = AfxGetResourceHandle();
AfxSetResourceHandle(hInst); 와 _USRDLL 전처리기 와의 상관관계를 반드시 찾아보라!DLL에서 이차이는 중요하다 DLL내부에서 핸들을 가져오지 못하는 경우가 발생할 수 있다.DLL내부에서 작동되는 자신의 코드가 무엇이냐에 따라 HINSTANCE hInst = GetModuleHandle(NULL); 을 해서라도 EXE의 핸들을 가져와야 할 지도 모른다! 단 이마저도 너무 크다고 생각이 되면 아주 줄이는 방법이 있다,즉 MSVC의 런타임 라이브러리 자체를 사용하지 않는 것이다.이에 대해 알려면 필자의 다른 글(
http://blog.hanafos.com/yeamaec/515 , http://blog.hanafos.com/yeamaec/518) 를 참조바란다.(코드프로젝트에서 libtc 검색)



*짜증나는 하나포스 블로그: 여기 편집기에서 저장만 했다하면 #include < ,> 문자(<,>으로 표현) 가 자꾸 사라진다. 개선하지 않으면 곧 이사가겠다.





My This blog moved from http://blog.hanafos.com/yeamaec

지푸라기의 비하인드스토리 http://blog.hanafos.com/yeamaec