티스토리 툴바

   개발자 로니강(Ronie.Kang)  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'Programming'에 해당하는 글(86)
2010/01/29   warning: braces around scalar initializer
2009/12/11   Porter-Duff 개념을 한눈에....
2009/12/02   큰 실수 -_-;;;; (5)
2009/11/15   [DirectFB] DirectFB에 Layer.... (8)
2009/10/07   [java]java 기본자료형
2009/10/05   [java] java Hello World (6)
2009/09/18   fatal error C1902: Program database manager mismatch; please check your installation
2009/09/18   /Za, /Ze(언어 확장 사용 안 함)
2009/09/10   Hex String to integer (1)
2009/09/10   ini 설정 파일에 특정 value 얻어오기
2009/07/21   warning: dereferencing type-punned pointer will break strict-aliasing rules (3)


warning: braces around scalar initializer
아래와 같이 선언된 배열은 warning: braces around scalar initializer와 같은
warning이 발생한다.

AC_CHAR8 *upKyes[20] = {
    {"User Language"},
    {"Country Code"},
    {"Default font size"},
    {"Parental Rating"},
    {"User Name"},
    {"User Address"},
    {"User @"},
    {"Post Code"},
    {"Audio Language"},
    {"Subtitle On"},
    {"Subtitle Language"},
    {"Teletext Language"}
};


아래와 같이 수정하면 워닝이 발생하지 않는다.

char *upKyes[] = {
   "User Language",
   "Country Code",
   "Default font size",
   "Parental Rating",
   "User Name",
   "User Address",
   "User @",
   "Post Code",
   "Audio Language",
   "Subtitle On",
   "Subtitle Language",
   "Teletext Language"
};
크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : C, C++, It, warning

name    password    homepage
 hidden


Porter-Duff 개념을 한눈에....
사용자 삽입 이미지


출처 : http://www.w3.org/TR/2002/WD-SVG11-20020215/masking.html


크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : It, Porter-Duff

name    password    homepage
 hidden


큰 실수 -_-;;;;
초보중에서도 초보가 할 수 있는 copy and paste를 통해서
아래와 같은 코드를 만들어 냈다. ㅜㅜ

하늘을 보기가 부끄럽다.!!!!
(친구 : "인간은 실수하는 동물"라는 말에 조금은 위로하고 Code Review에 힘써야겠다.)




void *xx_mem_get(size)
{
    void *mem = (void *)malloc(size);
    if(mem == NULL) {
        error ( ~ ~~~ );
    }

    return malloc(sizeof(size));
}



크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : It, malloc, Memory Leak, 메모리 누수, 바보짓, 실수
Commented by 윤경록 at 2009/12/10 19:48  r x
ㅠ.ㅠ 자책하지마..
내가 한 실수(덧셈 틀림 1+2=5)로 앞으로의 모든 배포가 그 실수를 포함하여 배포되도록 결정되어 버렸어. 하위 호환성 때문에.. OTL
Replied by 윤경록 at 2009/12/10 19:48 x
그래도 3밖에 차이 안나... ㅡㅠㅡ
Replied by 윤경록 at 2009/12/10 19:49 x
아... 2다..
Commented by 신동호 at 2009/12/16 05:50  r x
저게 정상적으로 실행되게 하는 방법은 없을까...?
Replied by Ronie.Kang at 2009/12/28 15:59 x
걍 수정 해버렸지요^^

name    password    homepage
 hidden


[DirectFB] DirectFB에 Layer....

뭔가 삽질을 시작하였는데 layer에 기본 개념이 잡히지 않아서 질문을 올려 봅니다.

1. 하나의 어플리케이션이
directfb을 통해서 4개의 layer를 가지며
각 layer는 한개씩 window을 각각 생성하고, 각 윈도우는 surface을 생성하여 가진다.
이게 맞는 것인지? 아니면

2. 하나의 어플리케이션이
directfb을 통해서 1개의 layer을 가지며
한개의 layer 통해서 4개의 Window을 생성하고, 각 윈도우는 각각에 surface 생성하여 가진다.

이게 맞는 것인지 -0- 혼란스럽 습니다.
어느게 개념상 맞는건가요?

1 번과 2번의 모두 가능하면 차이 점은 무엇인가요?


그럼 오늘도 행복한 하루 되세요.

크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : directfb, Linux
Commented by 암흑도깨비 at 2011/06/01 11:49  r x
우선 정답을 말씀을 드리자면은
1번과 2번 모두 맞는 말입니다.

즉 IDirectFB 라는 SuperInterface에 의해서 Layer가 존재하게 되는
거고 이 Layer는 다시 Window를 생성해서 Surface를 가지게 되는 것입니다.

IDirectFB *dfb; 이게 있다면은
이 dfb를 통해서 여러개의 layer를 만들어 줄 수 있으며,

하나의 layer에는 N개의 window 생성이 가능합니다. 하지만
그만큼 비디오 메모리가 충분해야지 가능한 것입니다.

그리고 window 또한 n개의 surface를 가질 수가 있습니다.
그러므로 1번과 2번 모두 맞다고 말씀 드릴 수가 있겠습니다.
Replied by Ronie.Kang at 2011/09/01 19:41 x
앗 암흑도깨비님 감사 드립니다.

한동안 바빠서 대충 포스팅한 글에 대해서
확인도 못 하고 있었습니다.

지금은 DirectFB에 windows, layer, surface에 대해서 모두 개념을 탑재 한 상태네요 ;;;


늦게나마 리플을 답니다.
감사 합니다.
Commented by google directory submission at 2012/04/09 11:18  r x
No matter what kind of business you have got, small or great, you will require your website to get a very good publicity. You will gain that utilizing the submission to directories service with directory submission issues.
Commented by writer job at 2012/04/11 11:41  r x
There’re lots of ways to get know about this topic. Guys would simply select job for writers service to find the facts that is wanted!
Commented by custom dissertation at 2012/04/12 04:39  r x
The best thesis can be longed-for by people all over the world but during the academic lifetime I need the dissertation service or unique model dissertation just about this post.
Commented by buy thesis at 2012/04/14 13:39  r x
The the web is flooded with custom thesis or format thesis just about this topic but to receive truly smashing dissertation, some people could use some hints.
Commented by buy essay at 2012/04/17 19:48  r x
The texts about this post are proposed by the writing service so, some of us are willing to buy custom essay papers or written essay about it.
Commented by america essay paper at 2012/04/20 14:43  r x
Here are some recommendations about the right way to get the academic success. Hence, students should read through the topic and accomplish the good enough europe essay paper. The other way is to look for the trustworthy online essay writing service and purchase essays online. We hope it helps some people.

name    password    homepage
 hidden


[java]java 기본자료형
논리형 자료형 : boolean
특징 : 형변환 블가

정수형 자료형 :
1. byte : 1byte (-128 ~ 127)
2. short : 2byte ( -32768 ~ 32767)
3. char : 2byte ( 0 ~ 65535 )
4. int : 4byte ( -2147483648 ~ 2147483647 )
5 long : 8byte (-922경 ~ 922경)

실수형 자료형
1. float : 4byte
2. double : 8byte



java에서 char이 유니코드를 저장하기 위해 16bit였다는걸 처음 알았음




char a = 32768;
short b = a;

char와 short의 type을 비교하시면 문제가 있는걸 알 수 있습니다.



casting 과 Promotion의 차이

casting : 강제
Promotion : 자동으로 casting
크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : It, Java, 자료형

name    password    homepage
 hidden


[java] java Hello World
JDK를 설치 하고, 처음으로 간단하게 작성해본 code

Test.java
public class Test {
    public static void main(String[] ar) {
        System.out.println("hello world");
    }
}


*  Java Code에서 첫 작성한 Class와 File 이름이 같아야 한다는 걸 알았다.


javac Test.java로 Build를 하면 output으로 Test.class가 생성이 되는데
이 파일을 Hex로 열어보면 아래와 같은 값들로 이루어진다.

사용자 삽입 이미지

java class File을 간단하게 분석 해보자
(본인도 처음 java code을 build 해보고 class 파일을 열어봄)

가장먼저 보이는건 Code 상에서 출력하도록 한 hello world가 보인다.
아무래도 *.class 파일은 일정한 File Format이 있는 것 처럼 보인다.
(아시는 분 있으면 간단하게 설명 부탁 드릴께요.!!! Plz)
Source File에 대한 정보로 파일 이름이 보인다.

아래 같은것들은 왠지 Test.java 파일에서 사용하는 class에 대한 경로 같기도 하다
(확인을 위해 jdk가 설치된 폴더를 찾아 보았지만 못 찾겠당 ㅜㅜ
java/lang/Object
java/lang/System out
Ljava/io/printStream;
java/io/PrintStream... println
(Ljava/lang/String;)V



실험 1.
Hex File에서 문자열을 수정해 보았다.
hello world --> Hello World

결과

java Test : Hello World로 Consol에 출력이 된다.



실험 2.
문자열의 길이를 수정하였다.
hello world --> hello world!!!!!

결과

C:\>java Test
Exception in thread "main" java.lang.ClassFormatError: Unknown constant tag 33 i
n class file Test
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Test.  Program will exit.

고찰1 :
이로써 javac로 빌드시에 string에 대해서는  static하게 길이를 계산해두는 것이라고 생각됨
그럼 간단하게 string length를 기록한 부분을 수정해주고? 다시 hex를 하게되면
올바른 결과가 보이지 않을까?

실험 3
위 그림에서 붉은색 네모 부분에 대해서 Edit를 하여 문자열을 눌려 보았다.

ASCII
hello world --> hello worlda

HEX
0B --> OC

결과: 정상적으로 출력이 되었다.
C:\>java Test
hello worlda

* 아하 javac를 통해 build시 문자열의 길이는 java class에 특정 부분에 쓰여지는구나!!!


의문 1 :
그럼 문자열이 두개 일경우에는 어떻게 될까?

가설 :
문자열에 대한 카운팅이 있을까?

결과: 없는 것 같다. ( 시간이 없어서 확인 못 함 )

우선 첫 시간으로 이정도만 확인해봄


참고하고 있는 자료
 * 열혈강의 동영상 강좌
 * 책도 없음 ;;;;; -0-



연구해볼 것
java class file format

크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : It, Java, The class File Format, 자바
Commented by 윤경록 at 2009/10/06 09:20  r x
완벽 매뉴얼이 있네.. http://jakarta.apache.org/bcel/manual.html 근데 왠 자바?
Replied by Ronie.Kang at 2009/10/06 10:12 x
MHP에서는 java를 다루기 때문이죠 ~ !

세컨 언어 대한 학습입니다. ^^
Commented by 윤경록 at 2009/10/07 00:33  r x
그렇다면 자바 하지마. MHP가 자바를 위해 만들어져 있어도 자바를 알 필요는 없어. 자바를 하려면 그저 언어에 대한 흥미로만 해.
Replied by Ronie.Kang at 2009/10/07 10:11 x
Yes Sir ~ !
Commented by 윤경록 at 2010/03/14 16:49  r x
나도 객체지향이라는 프로그래밍 방법론에 흠뻑 빠져보기 위해 자바를 시작했다!
Commented by sumin at 2011/12/29 11:21  r x
java/lang/Object
java/lang/System out
Ljava/io/printStream;
java/io/PrintStream... println

rt.jar 안에 들어가 있는 애들 아닌가요..?

name    password    homepage
 hidden


fatal error C1902: Program database manager mismatch; please check your installation

2003 .net으로 빌드 환경이 된 make를 vs 2005로 변환하는

삽질중에  mspdb80.dll(windows/system에 잡아 넣음)로 인하여 발생한 컴파일 에러 메시지

Big 삽질을 할뻔 했는데 다행이 관련 문제에 대해서

경험 해보신 분이 있어서 3분만에 삽질 마무리...


크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : Error Case, It, VC2005

name    password    homepage
 hidden


/Za, /Ze(언어 확장 사용 안 함)


/Ze 옵션은 Visual C++ 2005에서 사용되지 않습니다. 자세한 내용은 Visual C++ 2005의 사용되지 않는 컴파일러 옵션을 참조하십시오.

아래 링크를 참조 하시면 됩니다.

http://msdn.microsoft.com/ko-kr/library/0k0w269d.aspx

크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : compiler option, It, VC++, visual C++ 2005, 컴파일러 옵션

name    password    homepage
 hidden


Hex String to integer

이전에 포스팅한 GetProfileToString을 통해서, 특정 값을 읽어왔는데 제기럴 Hex 값이었다.
Int 값이었으면 atoi를 이용해서 int로 쓰겠는데 왠걸 hex string... 열심히 구글링 해보니 CodeProject에 Sample이 있어 업어왔다.


linux에서 왜 string.h에 strupr이 없는걸까???????
보안에 문제가 있는 API라서? 쩝....

Set로 움직이는 함수입니다.
꼭 필요한 분들이 있을 것 같습니다.

수정사항이 있으시면 언제든지!!!  피드백 부탁 드립니다.

고운하루 되세요


char* StrUpr( char *str )
{
    int loop = 0;
    while( str[loop] != '\0' )
    {
        str[loop] = (char) toupper( str[loop] );
        loop++;
    }
    return str;
}


/*
 * hex string to int
*/

int xtoi(char *value)
{
    struct CHexMap
    {
        char chr;
        int value;
    };

    const int HexMapL = 16;
    CHexMap HexMap[HexMapL] =
    {
        {'0', 0}, {'1', 1},
        {'2', 2}, {'3', 3},
        {'4', 4}, {'5', 5},
        {'6', 6}, {'7', 7},
        {'8', 8}, {'9', 9},
        {'A', 10}, {'B', 11},
        {'C', 12}, {'D', 13},
        {'E', 14}, {'F', 15}
    };

    /* remove space */
    int len = strlen(value);
    for(int i = 0; i < len; i++) {
        if( *(value+i) == ' ') {
            value++;
        } else {
            break;
        }
    }

    /* alloc buffer and change upper */
    char *mstr = StrUpr(strdup(value));
    char *s = mstr;
    int result = 0;
    if (*s == '0' && *(s + 1) == 'X')
        s += 2;
    bool firsttime = true;
    while (*s != '\0')
    {
        bool found = false;
        for (int i = 0; i < HexMapL; i++)
        {
            if (*s == HexMap[i].chr)
            {
                if (!firsttime) result <<= 4;
                result |= HexMap[i].value;
                found = true;
                break;
            }
        }
        if (!found) break;
        s++;
        firsttime = false;
    }
    free(mstr);
    return result;
}

크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : C, C++, It, Linux, strupr, xtoi
Commented by kuaaan at 2009/10/15 19:53  r x
strtol, strtoul 함수를 사용하세요. 세번째 인자에 16을 주면 16진수로 변환됩니다. atoi는 내부적으로 strtol에 세번째 인자로 10을 주어 재호출하는 것으로 알고 있습니다.
http://linux.die.net/man/3/strtol

name    password    homepage
 hidden


ini 설정 파일에 특정 value 얻어오기

linux에서도 이런 API가 있는지 모르겠어서
하나 간단하게 함수로 만들어 보았습니다.

머리가 나쁜면 손발이 고생한다고 하는데 -0-;
필요하신 분들이 있으면 잘 활용하셔요!

예외 처리등이 부실하니, 좀더 낳은 버전으로 수정 하시면
피드백 부탁 드리겠습니다.

그럼 고운하루 되세요.

/*
 * ex) test.ini
 *     [Data]
 *     value= 30
 *     .....
 *
 * ex) GetProfileToString("[Data]", "value=", buffer, "/tmp/test.ini");
 * 텍스트로 작성된 ini 등 에서 특정 섹션의 값을 읽어 온다.
 */
void GetProfileToString(char *section, char *keyName, char *string, char *fileFullPath)
{
    char tempBuffer[MAX_PATH] = { 0 };
    char *result = NULL;
    FILE *fp = fopen(fileFullPath, "rt");
    if (fp == NULL) {
        goto FINALLY;
    }
    while (fgets((char *)tempBuffer, MAX_PATH, fp)) {
        if (0 == strncmp(section, tempBuffer, strlen(section))) {
            memset(tempBuffer, 0, MAX_PATH);
            while (fgets((char *)tempBuffer, MAX_PATH, fp)) {
                if(tempBuffer[0] == '[') {
                    goto FINALLY;
                }
               
                if(0 == strncmp(keyName, tempBuffer, strlen(keyName))) {
                    char *p = (char*)tempBuffer;
                    p += strlen(keyName);
                    memcpy(string, p, strlen(keyName));
                    fclose(fp);
                    return;
                }
            }
        }
        memset(tempBuffer, 0, MAX_PATH);
    }
FINALLY:
    if (fp) {
        fclose(fp);
    }
    string = result;
}
크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : INI, It, Linux

name    password    homepage
 hidden


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


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

크리에이티브 커먼즈 라이선스
Creative Commons License
Tag : C, It, pointer casting, warning

name    password    homepage
 hidden


BLOG main image
개발자 로니의 스토리.... 삽질, 날샘, 야근, 개발, 자취생, 일상, 프로그래밍 개발, 등등등....
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (76)
아이폰 (0)
Books (3)
Programming (86)
BroadCast (12)
Personal Projects (6)
유용한 프로그램 (0)
비공개 (0)
 TAGS
빵꾸똥꾸 SIP 아이폰 C++ ubuntu itunes 동기화 iTunes Porter-Duff 토렌토 바보짓 VirtualBox iPhone M480 조중동 torrent C 인터넷전화 메모리 누수 벨소리 변경 myLG070 malloc 아이튠즈 MB 용자 가카 강남역 It arduino uno 스마트폰 sip 해킹 Linux 미라지 Memory Leak 벨소리 iphone 개발환경 directfb warning usb 인식 국내 토렌토 실수
 Calendar
«   2012/05   »
    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
Finding Memory Leaks Using t.. (3)
Program Arduino with AVR-GCC
새로운 장난감....
ATMEGA328P-PU
Arduino uno 간단한 보드 설명.
퇴근길 강남역에서 만난 도인?.. (1)
xper 5월 정기모임이 일정 (1)
국내 토렌토 주소 모음
미라지(SKT) M480 벨소리 변경..
myLG070 sip 추출하기 (3)
warning: braces around scala..
 Recent Comments
This posting on the..
MBA finance dissertation - 13:50
very nice blog and..
Management Thesis topic - 02:01
Here are some recom..
america essay paper - 04/20
Students’ life tim..
technology essays - 04/20
The texts about thi..
buy essay - 04/17
Some people like to..
buy essay - 04/17
The the web is floo..
buy thesis - 04/14
That is not really..
custom thesis - 04/14
The best thesis can..
custom dissertation - 04/12
The thesis service..
custom dissertation - 04/12
There’re lots of w..
writer job - 04/11
 Recent Trackbacks
COFDM 방식에서의 Bi..
Steve Yoon's log
다중포인터 읽기
.
 Archive
2011/09
2010/06
2010/05
2010/04
2010/02
2010/01
2009/12
2009/11
2009/10
2009/09
 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 : 89,279
Today : 1
Yesterday : 63
rss