IAR 환경에서 anonymous union 또는 anonymous struct가 사용될 경우 발생할 수 있습니다.
IAR 컴파일러에서는 anonymous union 또는 anonymous struct의 멤버 변수들을 전역변수처럼 접근해서 사용할 수 있습니다.
이로 인해 Controller Tester에서 분석 시 특정 변수들을 찾을 수 없는 에러가 발생합니다.
IAR의 특수한 문법에 대한 의미를 살리기 위해서는 anonymous union과 anonymous struct의 멤버 변수들을 전역 변수로 추가해야 합니다.

전역변수를 추가하는 방법은 아래와 같습니다.

  • ‘환경설정’ > ‘툴체인’ > 해당 툴체인 선택 후 ‘편집’ > ‘Predefined 선언’ > ‘Built-in 선언’ 에 변수 선언 추가

IAR anonymous union 사용 예제

__no_init volatile
union
{
 unsigned char IOPORT;
 struct
 {
 unsigned char way: 1;
 unsigned char out: 1;
 };
} @ 0x1000;
/* The variables are used here. */
void Test(void)
{
 IOPORT = 0; // union의 멤버 변수를 전역 변수 처럼 사용
 way = 1; // struct의 멤버 변수를 전역 변수 처럼 사용
 out = 1; // struct의 멤버 변수를 전역 변수 처럼 사용
}

툴체인에 추가한 전역 변수

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.