달력

42025  이전 다음

  • 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

git reference

Tool/git 2010. 7. 5. 20:54
git user manual
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html

git user manual 한글 번역본
http://namhyung.springnote.com/pages/3132772

git diagram 비롯한 사용법
http://osteele.com/archives/2008/05/my-git-workflow

git tutorial 1&2
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
http://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html

'Tool > git' 카테고리의 다른 글

git commit 복구하기  (3) 2010.12.08
git 알면 편한 기능  (0) 2010.11.13
git staic build  (0) 2010.04.27
git init --bare 이용  (1) 2010.04.23
git init --bare 발단  (0) 2010.04.23
Posted by neodelicious
|
공부 좀 하자.
그리고 정리를 잘 해서 필요할 때 바로 써 먹을 수 있도록 하자.

cmake example
   git clone git://github.com/neodelicious/cmake_example.git
pthread example
   git clone git://github.com/neodelicious/pthread_example.git

'Personal Interest > ETC' 카테고리의 다른 글

체리새우 깡...  (0) 2016.02.17
ubuntu 10.10 netbook version - unity  (0) 2010.11.14
홈페이지 텍스트큐브로 전환  (0) 2010.03.03
Eclipse bug in Ubuntu 9.10  (0) 2010.02.15
ssd 대신 tmpfs 을 쓰자  (0) 2010.02.14
Posted by neodelicious
|
프로그램을 짜다 보면 flag용으로만 사용하여 실제로는 1byte는 커녕 1bit만 할당해도 사용하는데 충분한 경우가 있다. 이때 bit 단위로 실제 사용 크기만큼만 할당해서 사용하면 메모리를 아낄 뿐 아니라 해당 변수를 복사할 때 빠를 것으로 생각된다.

물론 함수 내에서 잠깐 사용할 경우에는 int 로 선언해도 무방하고, 다른 모든 곳에서도 int 혹은 char 등으로 선언해도 사용하는데도 된다.

그러니까 아마도 주로 사용하는 struct 내에  Bool과 같이 단순 flag만으로 사용하는 변수가 많을 경우 유용할 것이다.

사용 방법은 간단한다.
변수 뒤에 ' : 크기' 와 같은 방식으로 bit 크기를 설정하면 되며, 주의할 것은 unsigned 를 붙여야 한다는 것이다.
예를 들어 unsigned char a1 : 1; 는 1 bit 크기를 할당한다.

관련해서 테스트 소스를 아래와 같이 작성했다.

#include <stdio.h>

struct Mystr {
 unsigned char a1 : 4;
 unsigned char a2 : 2;
 unsigned char a3 : 1;
};

int main(int argc, char *argv[])
{
 int i;
 struct Mystr mystr = { .a3=1, };

 printf("sizeof(struct Mystr) is %d\n", sizeof(struct Mystr));
 if (mystr.a3 == 1)
  printf(".a3=1 works!\n");

 return 0;
}
그 결과는 다음과 같다.
참고적으로 struct Mystr내 bit 크기가 8보다 큰 9라면 sizeof() 결과는 2가 된다.
그리고 unsigned char가 아닌 char 를 쓰면 '1'이 아닌 '0xFFFF'와 같은 값이 저장되어 문제가 된다.
sizeof(struct Mystr) is 1
.a3=1 works!

'Lang, Tool, Env' 카테고리의 다른 글

Linux version  (0) 2016.02.15
Ubuntu /home 옮기기  (0) 2012.08.04
struct timeval & long long  (0) 2010.03.31
IEEE Floating-Point Format  (1) 2009.09.13
chroot  (0) 2008.04.06
Posted by neodelicious
|