Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] What does this error mean?

2005-02-22 by Robert Adsett

At 05:45 PM 2/22/05 +0000, kc9dag wrote:
>I've done all my previous AVR programing in ASM and I program in C#
>on a daily basis so I figured I should finally learn C for the
>AVR...  Things have been going fine and now I am getting the
>following error:
>
>Datalogger.c: In function `main':
>Datalogger.c:48: error: redeclaration of 'inty' with no linkage
>Datalogger.c:48: error: previous definition of 'inty' was here
>Datalogger.c:48: error: parse error before '<' token
>Datalogger.c:48: error: parse error before ')' token
>Datalogger.c:48: warning: unused variable `inty'
>
>for this chunk of code:
>
>45  for(unsigned int x = 0; x <= pagecount; x++)

This would be valid C++ but not C

>46  {
>47      Page_To_Buffer(x, 1);
>48      for(unsigned int inty = 0, inty < 0xFF; inty++)

This would be valid C++ but not C

>49      {
>50              sendChar(Buffer_Read_Byte(1, inty));
>51      }
>52  }


Two ways of doing this in C.  Either at the top of the function

void func( void)
{
unsigned int x, inty;


Or in the enclosing loop (this is done far less often)

void func( void)
{
unsigned int x;

<code deleted>

for(x = 0u; x <= pagecount; x++)
        {
          unsigned int inty;

         Page_To_Buffer(x, 1);
         for(inty = 0u, inty < 0xFFu; inty++)
                   {
                 sendChar(Buffer_Read_Byte(1, inty));
                    }
          }

As to why the first for loop isn't giving an error, I don't know but I 
suspect that if you fix the inner loop, you'll suddenly find the outer loop 
now complains.

A copy of K&R or Harbison &  Steele  wouldn't go awry for covering these 
sort of details.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

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.