1452 views|7 replies

968

Posts

0

Resources
The OP
 

Is there any plugin or function in KEIL or other compilation environment that can help check if there is an error like if ( a=1 ) [Copy link]

邀请:@maychang   @damiaa   @vincentc543   @RichSJ   参与回复

Is there any plugin or function in KEIL or other compilation environment that can help check if there is an error like if (a=1)? Of course, this error is definitely not just if (a=1), it may also be if (aaa=1), if (xx=1), if (ekwks=1) and so on.

This post is from stm32/stm8

Latest reply

This post was last edited by damiaa on 2022-6-9 08:34 if (1==a) Comparison: In comparison, the right value (here the constant 1) can appear on the left. Assignment: An rvalue can appear on the right side of an assignment operator , but not on the left side . The constant 1 is an rvalue . if (1=a) the c compiler will give you an error.   Details Published on 2022-6-9 08:24
 

1w

Posts

142

Resources
2
 

String matching search.

This post is from stm32/stm8
 
Personal signature上传了一些书籍资料,也许有你想要的:http://download.eeworld.com.cn/user/chunyang
 

1790

Posts

0

Resources
3
 

It seems there was a warning.

This post is from stm32/stm8
 
 

6742

Posts

2

Resources
4
 

vscode has it.

This post is from stm32/stm8
 
 
 

114

Posts

6

Resources
5
 

You can try using cppcheck to check.

It should be possible to detect it.

This post is from stm32/stm8
 
 
 

2145

Posts

8

Resources
6
 

Keil does not report an error, but there is a warning...

This post is from stm32/stm8
 
Personal signature坐而言不如起而行
 
 

143

Posts

1

Resources
7
 

Generally, a warning will be given, such as Keil C51: warning C276: constant in condition expression

Because this is not a syntax error, just a warning, the build will continue to complete.

This post is from stm32/stm8
 
 
 

6062

Posts

4

Resources
8
 
This post was last edited by damiaa on 2022-6-9 08:34

if (1==a)

Comparison: In comparison, the right value (here the constant 1) can appear on the left.

Assignment: An rvalue can appear on the right side of an assignment operator , but not on the left side . The constant 1 is an rvalue .

if (1=a) the c compiler will give you an error.

This post is from stm32/stm8
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list