RFQ/BOM 0 로그인 / 등록하다

귀하의 위치를 선택하세요

사용자 이미지

The if statement encountered during C language debugging is invalid, but it can be executed.

MCU
11월 25, 2020 by Deja 1612

The phenomenon encountered when debugging the board.

The if statement does not hold true. The value of ret is 0, but the if (1==ret) statement can be executed. what's going on. Has anyone come across it? Please advise.

모든 댓글

user image

Krista 게시 날짜 November 25, 2020

I often encounter this situation. I don't know why, but the strange thing is that it doesn't affect my judgment in the end.

0
user image

Leona 게시 날짜 November 25, 2020

It should be the reason for compiler optimization. Just look at the assembly code. It is estimated that the code is still there in other places.

0
user image

Reggie 게시 날짜 November 25, 2020

1. Reduce the optimization level;

2. ret is defined as uint32_t;

0
user image

Dorothy 게시 날짜 November 25, 2020

I have encountered this. It should be a problem with the debugger. Sometimes the variable value displayed by the debugger is not updated in time. Because your ret is initialized to 0, you can try to initialize the ret to a different value when it is defined. Whether the initial value is displayed here.

0

답변 작성

답글을 달려면 로그인이 필요합니다. 로그인 | 등록하다