HCS08 Compiler Warnings

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

HCS08 Compiler Warnings

跳至解决方案
1,328 次查看
tayars
Contributor I

Hello,

 

I am new to the CodeWarrior 10.1 environment and I am using the HCS08 Compiler for my project.

In my code I noticed that a static variable was being created and initialized at the start of a function but was never used and no warnings were thrown up.

Is there a -Wall argument to invoke somewhere for this compiler? How can I make sure this isn't happening elsewhere without scouring every file?

 

Thanks in advance,

Tom

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,163 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

yes, there is an option to ignore all warnings: -W2.

But the compiler will not produce a warning for an unreferenced static local. A static local variable is handled like a global variable (with different access scope, of course), an if it is not used, the linker will dead strip/remove it.

 

But you can find the information that it has been removed in the linker map file here:

*********************************************************************************************
UNUSED-OBJECTS SECTION
---------------------------------------------------------------------------------------------

 

Otherwise you could use a tool like PC-lint to catch these kind of things.

 

Hope this helps,

BK

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,164 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

yes, there is an option to ignore all warnings: -W2.

But the compiler will not produce a warning for an unreferenced static local. A static local variable is handled like a global variable (with different access scope, of course), an if it is not used, the linker will dead strip/remove it.

 

But you can find the information that it has been removed in the linker map file here:

*********************************************************************************************
UNUSED-OBJECTS SECTION
---------------------------------------------------------------------------------------------

 

Otherwise you could use a tool like PC-lint to catch these kind of things.

 

Hope this helps,

BK

0 项奖励
回复
1,163 次查看
tayars
Contributor I

Hi BK,

 

Thanks for the help. I was actually hoping the compiler would offer an option to turn on all warnings without the help of a tool like PC Lint. (The opposite of using -W2). But I shall concede defeat to another tool I guess.

 

The information about the unused object sections is valuable, I did not know that kind of output was included in the map file. Thanks for that!

 

Tom

0 项奖励
回复
1,163 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

the S08 compiler is pretty verbose about variables/etc. But not in this case for static locals. Too bad in this case.

 

BK

0 项奖励
回复