Compiler Warning i.e. "Expression has no side effect" in .c file.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Compiler Warning i.e. "Expression has no side effect" in .c file.

2,986件の閲覧回数
mahamed_m
Contributor I

Compiler is generating a warning in .c when an API SetQuizBuckUFalt is called. The warning says expression has no side effect which means "statement does not change the program’s state", however the functionality is working fine for us but we need to understand why compiler is throwing a warning..?

### mwcceppc.exe Compiler:
#    File: ..\CHCM1P25\source\ostaskapi.c
# ---------------------------------------
#     506:       SetQuizBuckUFalt(SET_VAL); 
# Warning:                                ^
#   expression has no side effect

Compiler used: Freescale code warrior 2.10

Micro Controller: SPC564A80B4

Function definition:

uint8 VBuckFaltFlg;

/* The macro sets the VBuck fault flag to indicate the VBuck fault */


#define SetQuizBuckUFalt(SetValue) \
( (SetValue == SET_VAL)? (VBuckFaltFlg = SET_VAL):(VBuckFaltFlg = CLEAR_VAL) )

0 件の賞賛
返信
1 返信

2,638件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hello,

I consulted your question with my colleague and it seems, this warning occurs, because this SetValue == SET_VAL is always true in case you call SetQuizBuckUFalt(SET_VAL); with SET_VAL parameter.

Try to call SetQuizBuckUFalt with variable parameter not with constant parameter.

Regards,

Martin

0 件の賞賛
返信