Yahoo Groups archive

AVR-Chat

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

Message

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:
>
> 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
> >
>

Attachments

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.