HCS08 Compiler Warnings

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HCS08 Compiler Warnings

Jump to solution
1,324 Views
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

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,159 Views
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

View solution in original post

0 Kudos
Reply
3 Replies
1,160 Views
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 Kudos
Reply
1,159 Views
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 Kudos
Reply
1,159 Views
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 Kudos
Reply