<avr/io.h> question

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

In the progress of debugging my application I found out that I didn't need to include in any of my .c files.

I searched the makefile and WinAVR release notes, but couldn't find anything to clarify how this file is being included.

If I re-name io.h everything falls over so I know that "something" is finding the io.h without it being included in my source.

Can anyone explain what that "something" is?

Using WinAVR-20060421

Thanks

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

What other headers are you using? If any of the LibC headers are included they include too, since they require functions from it. The LibC headers use #ifndef protection to ensure that no problems arise from including the same header file multiple times.

Short answer, always put in the #include as it's good practise, and will prevent future code from breaking if you don't use any of the other LibC functionality.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

> in any of my .c files.

I tested by commenting-out any #include in other files that I used, i.e. AVRlib uart.c, buffer.c and adc.c

I'll write a simple pogram with only one file and see what happens.

Thanks,
Dave

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

Why go to the effort of removing all the references to IO.H? Is it going to needlessly consume space if left in? I thought that optimization would remove any extraneous junk like this automatically.

-Tony

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

Why? Just to try to understand what was linking in io.h.

Dean,
As per your suggestion I see that io.h is linked in with avr/interrupt.h>, but the particular file I am looking at does not include interrupt.h or any other AVRlibc or AVRlib files.

My understanding is that if you want to use something like (1<<PC2) in a specific .c file then you should have to include io.h
Right?

Just curious.
Dave

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

Yes that's correct. I'm not sure why you're seeing io included with no external files. Is your makefile a custom one which is including it there?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Just the makefile that came with WinAVR-20060421. This all started with tracking down that enum error problem. I was getting indications from the compiler that some files "appeared" like they did NOT have io.h included in them. When I fixed the enum issue then it seemed like you didn't need io.h included.

I'll try a real simple program, to try and understand what is going on.