skip to main | skip to sidebar

Core-Station :: Client-Server

2008-12-18

STRUCT 키워드에서 :1 사용법


here is a little feature that allows you to save a little space.
main()   
{
     struct Flags
     {       
   unsigned int Online  :1;
          unsigned int Mounted :1;
     }
     struct Flags TapeInfo;
     TapeInfo.Online  = 1;
     TapeInfo.Mounted = 0;
}    

The :1 tells the compiler that only 1 byte is required for Online and Mounted. There are a few points to note about this though.

  • You may expect the compiler to reserve 2 bytes for the structure, it actually reserves one word (usually 4 bytes) as this is the smallest unit that can be reserved, the remaining 2 bytes are unavailable. This is still better than the 2 words that wold normally get reserved.
  • You can put any number into the variable, if the number is too large to fit, the high order bits are lost without warning.
  • Only signed int, unsigned int, int support this syntax.

출처 : http://www.space.unibe.ch/comp_doc/c_manual/C/SYNTAX/struct.html
작성자: CoRe 위치 11:20
레이블: :1, struct

0 개의 덧글:

Post a Comment

최근 게시물 이전 게시물 홈
블로그 피드: 게시물 덧글 (Atom)

레이블

  • erlang (4)
  • emacs (2)
  • gentoo (2)
  • udp (2)
  • 리눅스 (2)
  • 삶 (2)
  • :1 (1)
  • Attack (1)
  • LANGUAGE (1)
  • RTP (1)
  • TimeArithmetic (1)
  • VoIP (1)
  • apache (1)
  • automake (1)
  • bitrate (1)
  • branch (1)
  • check sum (1)
  • color (1)
  • ecb (1)
  • evaluation (1)
  • freebsd (1)
  • gcc (1)
  • gpasswd (1)
  • libtool (1)
  • msrp (1)
  • multicast (1)
  • nate-on (1)
  • packet (1)
  • rails (1)
  • rdp (1)
  • ruby (1)
  • sip (1)
  • sleep (1)
  • ssh (1)
  • struct (1)
  • su (1)
  • super computing (1)
  • tag (1)
  • tcp (1)
  • time diff (1)
  • tty (1)
  • tunneling (1)
  • via (1)
  • windows 2008 (1)
  • wireless (1)
  • 경제 (1)
  • 대학원 (1)
  • 슈퍼 컴퓨팅 (1)
  • 시간 계산 (1)
  • 시스템 설정 (1)
  • 원격 데스트탑 (1)
  • 유비쿼터스 컴퓨팅 (1)
  • 재테크 (1)
  • 창의 (1)
  • 책 (1)
  • 회사 (1)

블로그 아카이브

  • 6월 18 (1)
  • 6월 16 (1)
  • 5월 18 (1)
  • 4월 15 (1)
  • 1월 08 (1)
  • 12월 18 (3)
  • 12월 17 (1)
  • 12월 15 (2)
  • 12월 14 (1)
  • 12월 12 (1)
  • 12월 11 (2)
  • 12월 09 (1)
  • 11월 29 (1)
  • 11월 03 (1)
  • 10월 21 (2)
  • 10월 06 (1)
  • 9월 30 (1)
  • 9월 22 (1)
  • 9월 20 (1)
  • 9월 19 (2)
  • 9월 18 (1)
  • 9월 04 (1)
  • 9월 01 (1)

개인 정보

내 사진
CoRe
전체 프로필 보기