최대 1 분 소요

#include

#ifdef ___________index__________

cmdParam = (FIFO_CMD_PARAMETERS*) &irsock_cmd->cmd_data.cmd_params;

FIFO_CMD_PARAMETERS union type
irsock_cmd struct type
cmd_data struct type
cdm_params FIFO_CMD_PARAMETERS type
cmdParm == FIFO_CMD_PARAMETERS *type

포인터 변수를 연결하여 사용하는 방법인데.. 음 한번써봐야 하지 않을까?

결론은 두개의 값을 동기화 시키기 위해서 쓴것으로 판명… ㅡ.ㅡ;

#endif

// 구조체 선언을 할때는 미리 변수를 입력하지 않는다.
typedef struct{
int i;
int j;
}test_struct;

union{
int i;
int j;
}test_union;

int main(int argc, char *argv[])
{
test_struct test_struct_;
test_struct * test_struct_pointer;

test_struct_.i=1;
test_struct_.j=1;

test_struct_pointer = (test_struct *)&test_struct_;

printf(“%d %d
“, test_struct_.i, test_struct_.j);

test_struct_pointer->i=2;
test_struct_pointer->j=2;

printf(“%d %d
“, test_struct_.i, test_struct_.j);

return 0;
}
\

태그:

카테고리:

업데이트: