Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Strange compiler warnings?

Strange compiler warnings?

2007-04-17 by Richard Cooke

Hi Folks,

This is probably something I'm overlooking but can somebody point me
in the right way concerning this?

I need to add this to one of the header files:

#define  SPIF     7  // bit position for the SPIF bit in the SPSR 

If I add this I get 8 warnings complaining 
"Unreferenced function 'Function1'"
"Unreferenced function 'Function2'"
"Unreferenced function 'Function3'"
"Unreferenced function 'Function4'"
"Unreferenced function 'Function5'"
"Unreferenced function 'Function6'"
"Unreferenced function 'Function7'"
"Unreferenced function 'Function8'"

I have properly (I think) defined these functions as prototypes in the
Header file.  If I remove the #define SPIF  7 line the warnings all go
away but then the compiler gives me two errors complaining that SPIF
is undefined.  

I'm using the latest CodeVision.

Any ideas?

Thanks,

Richard Cooke

Re: Strange compiler warnings?

2007-04-17 by Richard Cooke

Yes, they are called from the C file.  It was a very late night last
night and I finished (at least I thought I had) part of the code.  I
didn't actually add the C file into the project until this morning.  A
s soon as I actually called the functions the warnings went away.

Thanks for jogging my brain awake.

Richard

--- In AVR-Chat@yahoogroups.com, Ralph Hilton <ralph@...> wrote:
Show quoted textHide quoted text
>
> On Tue, 17 Apr 2007 16:03:56 -0000 you wrote:
> 
> Are you actually calling the functions somewhere?
> 
> >Hi Folks,
> >
> >This is probably something I'm overlooking but can somebody point me
> >in the right way concerning this?
> >
> >I need to add this to one of the header files:
> >
> >#define  SPIF     7  // bit position for the SPIF bit in the SPSR 
> >
> >If I add this I get 8 warnings complaining 
> >"Unreferenced function 'Function1'"
> >"Unreferenced function 'Function2'"
> >"Unreferenced function 'Function3'"
> >"Unreferenced function 'Function4'"
> >"Unreferenced function 'Function5'"
> >"Unreferenced function 'Function6'"
> >"Unreferenced function 'Function7'"
> >"Unreferenced function 'Function8'"
> >
> >I have properly (I think) defined these functions as prototypes in the
> >Header file.  If I remove the #define SPIF  7 line the warnings all go
> >away but then the compiler gives me two errors complaining that SPIF
> >is undefined.  
> >
> >I'm using the latest CodeVision.
> >
> >Any ideas?
> >
> >Thanks,
> >
> >Richard Cooke
> 
> --
> Ralph Hilton
> http://www.ralphhilton.org
> C-Meter: http://www.cmeter.org
> FZAOINT http://www.fzaoint.net
>

Re: Strange compiler warnings?

2007-04-17 by Bruce Parham

Watch out how you comment defines. SPIF will be replaced with a "7" and
the rest of the line will be commented out. If you must comment inline,
use a block comment:

    #define  SPIF     7  /* bit position for the SPIF bit in the SPSR */

to preserve the rest of the line.

Bruce 


--- In AVR-Chat@yahoogroups.com, "Richard Cooke" <rcooke@...> wrote:
Show quoted textHide quoted text
>
> Hi Folks,
> 
> This is probably something I'm overlooking but can somebody point me
> in the right way concerning this?
> 
> I need to add this to one of the header files:
> 
> #define  SPIF     7  // bit position for the SPIF bit in the SPSR 
> 
> If I add this I get 8 warnings complaining 
> "Unreferenced function 'Function1'"
> "Unreferenced function 'Function2'"
> "Unreferenced function 'Function3'"
> "Unreferenced function 'Function4'"
> "Unreferenced function 'Function5'"
> "Unreferenced function 'Function6'"
> "Unreferenced function 'Function7'"
> "Unreferenced function 'Function8'"
> 
> I have properly (I think) defined these functions as prototypes in the
> Header file.  If I remove the #define SPIF  7 line the warnings all go
> away but then the compiler gives me two errors complaining that SPIF
> is undefined.  
> 
> I'm using the latest CodeVision.
> 
> Any ideas?
> 
> Thanks,
> 
> Richard Cooke
>

Re: [AVR-Chat] Strange compiler warnings?

2007-04-17 by Ralph Hilton

On Tue, 17 Apr 2007 16:03:56 -0000 you wrote:

Are you actually calling the functions somewhere?

>Hi Folks,
>
>This is probably something I'm overlooking but can somebody point me
>in the right way concerning this?
>
>I need to add this to one of the header files:
>
>#define  SPIF     7  // bit position for the SPIF bit in the SPSR 
>
>If I add this I get 8 warnings complaining 
>"Unreferenced function 'Function1'"
>"Unreferenced function 'Function2'"
>"Unreferenced function 'Function3'"
>"Unreferenced function 'Function4'"
>"Unreferenced function 'Function5'"
>"Unreferenced function 'Function6'"
>"Unreferenced function 'Function7'"
>"Unreferenced function 'Function8'"
>
>I have properly (I think) defined these functions as prototypes in the
>Header file.  If I remove the #define SPIF  7 line the warnings all go
>away but then the compiler gives me two errors complaining that SPIF
>is undefined.  
>
>I'm using the latest CodeVision.
>
>Any ideas?
>
>Thanks,
>
>Richard Cooke

--
Ralph Hilton
http://www.ralphhilton.org
C-Meter: http://www.cmeter.org
FZAOINT http://www.fzaoint.net

Re: Strange compiler warnings?

2007-04-17 by kernels_nz

Excellent catch about using comments in defines, it has caught me out
in the past because:

#define max 100 //largest value  

in the line 

for (count = 0; count < max; count++)

will turn into something like:

for (count = 0; count < 100 //largest value; count++)

which obviously wouldnt work.

Good Catch Bruce !

Cheers
Hein B
Auckland, New Zealand

--- In AVR-Chat@yahoogroups.com, "Bruce Parham" <obparham@...> wrote:
Show quoted textHide quoted text
>
> Watch out how you comment defines. SPIF will be replaced with a "7" and
> the rest of the line will be commented out. If you must comment inline,
> use a block comment:
> 
>     #define  SPIF     7  /* bit position for the SPIF bit in the SPSR */
> 
> to preserve the rest of the line.
> 
> Bruce 
> 
> 
> --- In AVR-Chat@yahoogroups.com, "Richard Cooke" <rcooke@> wrote:
> >
> > Hi Folks,
> > 
> > This is probably something I'm overlooking but can somebody point me
> > in the right way concerning this?
> > 
> > I need to add this to one of the header files:
> > 
> > #define  SPIF     7  // bit position for the SPIF bit in the SPSR 
> > 
> > If I add this I get 8 warnings complaining 
> > "Unreferenced function 'Function1'"
> > "Unreferenced function 'Function2'"
> > "Unreferenced function 'Function3'"
> > "Unreferenced function 'Function4'"
> > "Unreferenced function 'Function5'"
> > "Unreferenced function 'Function6'"
> > "Unreferenced function 'Function7'"
> > "Unreferenced function 'Function8'"
> > 
> > I have properly (I think) defined these functions as prototypes in the
> > Header file.  If I remove the #define SPIF  7 line the warnings all go
> > away but then the compiler gives me two errors complaining that SPIF
> > is undefined.  
> > 
> > I'm using the latest CodeVision.
> > 
> > Any ideas?
> > 
> > Thanks,
> > 
> > Richard Cooke
> >
>

Re: [AVR-Chat] Re: Strange compiler warnings?

2007-04-17 by Dave Hylands

Hi guys,

On 4/17/07, kernels_nz <kernels@slingshot.co.nz> wrote:
> Excellent catch about using comments in defines, it has caught me out
> in the past because:
>
> #define max 100 //largest value
>
> in the line
>
> for (count = 0; count < max; count++)
>
> will turn into something like:
>
> for (count = 0; count < 100 //largest value; count++)
>
> which obviously wouldnt work.

Actually, that should work just fine. Because according to the
language specification comments are supposed to be treated as white
space.

I know that GCC will actually replace comments with whitespace prior
to passing the code onto the compiler. Perhaps other compilers aren't
doing the right thing...

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.