AVR/GNU Compiler Switch "-I"

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

Wondered what the "-I" switch is, specifically why GccStaticLibraryCore2 has it and GccStaticLibraryTWI1 doesn't?

 

-DDEBUG -DARDUINO=100 -DF_CPU=16000000L  -I"../../GccStaticLibraryCore2" -I"../../GccStaticLibraryTWI1"  -O1 -ffunction-sections -fdata-sections -g2 -Wall -mmcu=atmega328p -c -fno-exceptions -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"

This topic has a solution.
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The GCC manual is online here:

 

https://gcc.gnu.org/onlinedocs/g...

 

The -I switch is explained here:

 

https://gcc.gnu.org/onlinedocs/g...

(it's on that page because it's really an instruction to the preprocessor not the compiler itself)

 

It adds search directories to the search path for any #inlcude "...", but not #include <...>

 

In your example above the preprocessor is being told of two other places to look for .h files when it encounters #include's (by default it will just look in the current source directory for the ../.. in the paths given are relative to that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
     -I dir
         Add the directory dir to the list of directories to be
         searched for header files.  Directories named by -I are
         searched before the standard system include directories.
         If the directory dir is a standard system include
         directory, the option is ignored to ensure that the
         default search order for system directories and the
         special treatment of system headers are not defeated .

from gcc man pages

Computers don't make errors - What they do they do on purpose.

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

RTFM: https://gcc.gnu.org/onlinedocs/c...

 

Hint: to find such things with a google search, you need to enclose the -I in quotes, thus:

"-I"

otherwise google takes the '-' to mean, "ignore this" 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

otherwise google takes the '-' to mean, "ignore this" 

No, it's worse than that. In Google -<something> means "don't give me any results that contain <something>". In this case it would therefore filter out any result with the letter "I" used in it.

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

Thanks for that.

 

I had looked at the Atmel documentation - http://www.atmel.com/webdoc/atmelstudio/atmelstudio.section.gcc8.common.html but got nothing.

 

I still cannot find the setting in the AS Toolchain GUI. The preprocesser, and indeed all other settings appear identical in GccStaticLibraryCore2 and GccStaticLibraryTWI1 toolchains. Guess I must have missed something.

 

 

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

I had looked at the Atmel documentation

Sorry, I know Atmel tries, but that documentation is complete rubbish.frown

 

Rather ironically any implementation of GCC should have a ./doc/ directory with hard drive copies of all the manual I linked to above and Atmel Studio (well at least recently) is no different. On my AS6 machine I find the GCC manual under:

 

C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\share\doc\gcc

 

and the binutils/ld/other manuals under

 

C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\doc

 

All the manuals are provided as linked .html files - start with the top level "index" one and use your browser to navigate from there.

 

Personally I just find it easier to google "gcc manual online" or if I want a specific version "gcc 4.8.1 manual online".

 

As to where you specify such things in the IDE: take a look here:

 

http://www.atmel.com/webdoc/atme...

 

Under "AVR/GNU C Compiler" there is a section called "Directories". For each entry you make there an additional -I will be passed to the compiler/preprocessor.

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

clawson wrote:

Under "AVR/GNU C Compiler" there is a section called "Directories". For each entry you make there an additional -I will be passed to the compiler/preprocessor.

But that is not happening. A project with one or more Directory entries usually puts just a single "-I".

But the project 'GccStaticLibraryTWI1' has 2 directory entries - one referencing self and the other GccStaticLibraryCore2. And the -I switch is absent.

 

Have just upgraded AS6.2 to SP2, but did a clean install so hopefully it is not that that is the problem.

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

 A project with one or more Directory entries usually puts just a single "-I".

That's not possible - that's not how GCC's -I option works. You need a separate -I for each additional directory you want to add to the header search path. So if you add 5 entries under "Directories" you should see the IDE passing five -I "..." on the command line. if the IDE is not forming the -I's in this way it's likely a bug in the IDE.

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

iBeta666 wrote:
A project with one or more Directory entries usually puts just a single "-I".

No: As Cliff says, that is not correct!

 

Post a screenshot of how you're filling-in the GUI form - you're not trying to put multiple directories into a single entry, are you...?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

No: As Cliff says, that is not correct!

Post a screenshot of how you're filling-in the GUI form - you're not trying to put multiple directories into a single entry, are you...?

 

Ok, sorry. I think I misunderstood and thought clawson meant a series of "-I"'s after each other.

 

Even more embarrasingly, after looking at the screen shots, the I's are all there. I had thought that the switch would come after the entry, but missed/ignored the first one, so if that is correct then there is no problem - all entries are preceeded by an "-I".

 

Sorry to all for wasting your time.