compiler behaves erratic

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,
I am using WinAvr by creating projects and writing code with out any problems. Yesturday I created a new project and wrote some code and tried to compile and I got errors such as UDR not declared etc. (i am using serial port). If I close this project and open an existing one and compile there are no errors reported! but any new project is throwinng up errors. What could have gone wrong? Any help will be highly appreciated. Thank you.

Regards

Parthasaradhi Nayani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hard to tell without more info, but it sure smells like your makefile is corrupted.

Assumptio mater errorum est

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you selecting the correct processor in your makefile? For example: MCU = atmega8

Did you #include ?

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,
Thanks for all the replies. Yes I am using the correct processor. Don, I had never included the file. This file is automatically selected depending on the processor selected when you include STDIO.H file. I am not sure if the Makefile is currupted because I created a mkaefile using Mfile. Any more suggestions please?

Regards
Nayani

Parthasaradhi Nayani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nayani, what processor are you using?

The ATmega48, ATmega88 and ATmega168, for example, don't have a UDR register.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> Don, I had never included the file. This file is
> automatically selected depending on the processor selected when you
> include STDIO.H file.

Sheesh, don't rely on undocumented side effects! is *not*
documented to #include , so please, do include the latter
explicitly yourself.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,

I do not know how other programmes worked without reporting any errors till date! Only this one started throwing up errors. Yes the errors stopped when I include the avr/io.h file. But the behaviour is very strange.

Don, I am using Atmega8, which has a UDR and now the programme is copiling without errors upon inclusion of avr/io.h

Thank you all and regards

Parthasaradhi Nayani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nayani, Jörg makes a good point about not relying on undocumented side effects.

I just did a print of the header files (using the avr-gcc -H flag) and what I see is that stdio.h included stdarg.h and stddef.h. stdio.h did not include io.h.

In my test, I was including interrupt.h which did include io.h. io.h in turn includes iom8.h for the ATmega8.

You probably got away with not including io.h because some other header file (like interrupt.h) was including it.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And in the end, if you need access to/from any register then include . It only takes one line, and then you're done with it. You can include it as many times as you want to and it won't cause any conflicts either.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don,
Thanks for your time. That answers the question. Yes I was including SIGNAL.H file in my earlier programmes and perhaps this is the reason errors were not reported.

EW,
Normally 'C' compiler generates errors, if a defined constant is redefined (though with the same value), how is it that GCC does not find it an error (since you mentioned that you may include the header file as many times as one wishes), In fact I was wondering why the compiler was not reporting an error when I used a #define more than once. Clarification on this will be highly appreciated. Thanks in advance for your time.

Regards

Parthasaradhi Nayani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nayani P wrote:

EW,
Normally 'C' compiler generates errors, if a defined constant is redefined (though with the same value), how is it that GCC does not find it an error (since you mentioned that you may include the header file as many times as one wishes), In fact I was wondering why the compiler was not reporting an error when I used a #define more than once. Clarification on this will be highly appreciated. Thanks in advance for your time.

Regards

It's a C language FAQ:
http://www.eskimo.com/~scs/C-faq/q10.7.html