IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'2009/07'에 해당하는 글(5)
2009.07.22   소스 인사이트 - tab을 space로....
2009.07.21   warning: dereferencing type-punned pointer will break strict-aliasing rules
2009.07.17   Iimage 를 이용하여 jpeg 출력 2
2009.07.01   [warning]suggest parentheses around assignment used as truth value
2009.07.01   Hello World가 실행 파일이 될때까지...


소스 인사이트 - tab을 space로....
alt + t를 누름
1. Tab width를 4 로 설정
2. Expand tab을 enable로 설정
3. Auto Indent는 취향에 맡게 simple에 체크 둘다 해주는거...

tab --> space로 일괄 변경
1. 소스 전체 선택
2. alt+ e
3. special  --> tab --> space 누름

정해진 tab width만큼으로 모두 변경됨


warning: dereferencing type-punned pointer will break strict-aliasing rules

Wall로 Build 를 하는데 아래와 같은 워닝이 발생해서

warning: dereferencing type-punned pointer will break strict-aliasing rules

구글링좀 하고, 고치기 귀찮아서  MakeFile만 수정해서 올림
연구원 씨가 관심 있으면 고치겠지.....



The following short examples demonstrate my problem:

----Exhibit A
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int foo;
    int bar;
} item_t;

int return_item (void **item);

int return_item (void **item)
{
    void *mem;

    mem = malloc (1);
    if (mem) {
        *item = mem;
        return 0;
    }
    else
        return 1;
}

int main (int argc, char *argv[])
{
    item_t *item;

    if (return_item ((void **)&item) == 0) {
        printf ("%p\n", item);
        free (item);
    }

    return 0;
}

----Exhibit B
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int foo;
    int bar;
} item_t;

int return_item (void **item);

int return_item (void **item)
{
    void *mem;

    mem = malloc (1);
    if (mem) {
        *item = mem;
        return 0;
    }
    else
        return 1;
}

int main (int argc, char *argv[])
{
    item_t *item;
    void *item_temp;

    if (return_item (&item_temp) == 0) {
        item = item_temp;
        printf ("%p\n", item);
        free (item);
    }

    return 0;
}
----

The code is a generic example of the problem.  The real code that is
producing the problem is a hashing API which hashes (void *) and hence
uses (void **) as an out parameter type. 

Exhibit A produces a warning as follows:

[nodbug:mato]$ gcc -O2 -Wall -o aliasing-test aliasing-test.c
aliasing-test.c: In function `main':
aliasing-test.c:28: warning: dereferencing type-punned pointer will break strict-aliasing rules

I'm using gcc version 3.3.5 (Debian 1:3.3.5-13) but the problem persists
even when tested with GCC 4.x on newer systems.

Exhibit B is my proposed "fix".  Can anyone advise if the code in
Exhibit A is legitimate, i.e. whether or not it's really violating the
strict aliasing rules as defined by the C standard?  If not, then I
guess the warning is spurious and I can safely use the fix.

If the code is in fact violating the standard then feel free to
enlighten me how to fix it, since it seems like a legitimate thing to do
:-)

Thanks very much for any help,
귀차나서 그대로 긁어 왔습니다.

참고 : http://gcc.gnu.org/ml/gcc-help/2006-08/msg00236.html


음 문제가 되면 삭제 하겠습니다 훗..



Iimage 를 이용하여 jpeg 출력

참 쉽죠이잉 ~
wince5.0에서 10분이면 되는걸... !!
일 할때는 다른 사람의 경험을 존중하며 가장 손쉬운 방법을 찾는걸 우선 해야 할 것입니다.
고민 할껀 고민 해야겠죠

Windows CE 5.0이상에서 지원, Imaging관련 컴포넌트가 포함된 경우에만 동작
확인은 dll이 있는지 확인 해봐야함

기본적으로 지원하는 포맷은 jpg, png, gif, bmp 등이 있고 multiframe image(ani-gif)도 가능하며, 유저 코덱을 추가하면 다른 포맷도 사용 가능합니다.인코딩, 디코딩 가능하며, contrast, brightness, flip, clone, resize, rotate 등도 가능

일전 이미지 편집 프로그램을 windows mobile 5.0에서 간단한 이미지 편집 프로그램
작성시 해당 컴포넌트 이용, Thumnail 엔진도 이용함.

자세한 사항은 MSDN에서  http://msdn.microsoft.com/en-gb/library/ms932606.aspx 확인



1. 헤더, 라이브러리 추가

#include <initguid.h>
#include <imaging.h>
#pragma comment (lib, "Ole32.lib")


2. ImagingAPI를 사용하기 전후로 다음 함수 호출합니다.
   이유는 COM을 사용하기 때문이죠. 프로그램 시작/종료시에 한번만 호출 합니다.
  
 
    // 프로그램 시작부분에서 호출.
    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);   


    // 프로그램 종료부분에서 호출..
    CoUninitialize();   


3. 이미지파일을 읽어와서, hdc의 rcDest 영역에 display sample function


void DrawImageFile(HDC hdc, TCHAR* szFileName, RECT* prcDest)

{

    HRESULT hr;

    IImage *pImage = NULL;

    IImagingFactory *pImagingFactory = NULL;


    hr = CoCreateInstance(CLSID_ImagingFactory,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IImagingFactory,
                          (void**) &pImagingFactory);

    if( FAILED(hr) ) {
 goto finish;
    }
 

    hr = pImagingFactory->CreateImageFromFile( szFileName, &pImage );

    if (FAILED(hr) || NULL == pImage) {
 goto finish;
    }

    pImage->Draw( hdc, prcDest, NULL );

finish:
    if (pImage) {                
 pImage->Release();
 pImage = NULL;
    }

    if (pImagingFactory) {
 pImagingFactory->Release();
        pImagingFactory = NULL;
    }
}


4. draw....

win32 api를 이용시...

    HDC hdc;
    PAINTSTRUCT ps;
    hdc = BeginPaint(hWnd, &ps);

    // 이미지가 보일 좌표
    RECT rectDest= {0,0,200,200};
    DrawImageFile(hdc, L"\\test.jpg", &rectDest);

    EndPaint(hWnd, &ps);



iimage도 잘 이용하면 더블버퍼링 처리가 가능 합니다.

hdc에 바로 그리지 말고, mem dc에 그린 후 hdc로 옮겨 그리면,
깜빡임 현상들을 제거 할 수 있습니다.

일단 샘플이니 간단하게 사용 해보셔요.



[warning]suggest parentheses around assignment used as truth value

워닝 발생

if ( x = getSomethingValue())
{
 ........
}

해결방법
if ( (x = getSomethingValue()) )
{
 ........
}

KIN.....



Hello World가 실행 파일이 될때까지...
우선 간단하게 컴파일이 되는 아래 Hello World를 작성한다.

helloworld.c



컴파일러들을 이용하여 실행할 수 있는
실행 파일로 만드는 과정을 간단하게 적어 보면

Preprocessor --> Compiler -->Assembler  --> Linker & Relocation--> executableFile

1. 컴파일러는 helloworld.c 파일을 읽어들인다.
    (확장자에 따라 c / c++로 인식)

2. helloworld.c에 Code를 오브젝트 파일로 만든다.

3. 중간 목적 파일(기계어)로 변경한다 .

4. 중간 목적 파일을 링커 프로그램으로 연결한다.

5. exe  실행파일


BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (190)
매일매일갱생 (82)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
Wince5.0 DVB-T english email 알고리즘 C++ warning Linux Debug DirectShow 음식 VC++ debugging ISDB-T 티스토리 초대장 군대 1seg Brazil 미라지폰 project 퇴사 출장 벨소리 변경 영어 이메일 DVB Windows Mobile6.0 It Error Case 서태지 MP3 티스토리초대 C isdbt Algorithm M480 개발자 English Java spam mail Dshow
 Calendar
«   2009/07   »
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 31
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss