Groups
Conversations
All groups and messages
Send feedback to Google
Help
Training
Sign in
Groups
han.comp.lang.c
Conversations
About
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
C언어 비트필드 공용체 사용 문의 건
39 views
Skip to first unread message
ejyl...@gmail.com
unread,
Feb 27, 2018, 12:11:14 AM
2/27/18
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
공용체와 비트필드 아래와 같이 사용하고 있습니다.
컴파일러 특성상 MSB 먼저 저장됩니다.
typedef union
{
unsigned char mask;
struct {
unsigned char Reserved : 5;
unsigned char Bit3 : 1;
unsigned char Bit2 : 1;
unsigned char Bit1 : 1;
}BIT;
}
BitTest_t;
BitTest_t Test;
Test.mask = 0x05;
예를들어 Test.mask 에 위와 같이 입력후 아래와 같이 if 문으로 BIT 를 사용하면
else 문으로 빠져야 함에도 불구하고 if 구문 안으로 들어갑니다.
디버거를 통해 Test.BIT.Bit3 와 Test.BIT.Bit1 를 확인하면 둘다 1 이라는 값이 잘 들어와있는데..
혹시 아래와 같이 비트 필드를 사용하는데에 문제점이 있는지요?
if((Test.BIT.Bit3 == 0) || (Test.BIT.Bit1 == 0))
{
}
else
{
}
0 new messages