Search code examples
embeddedworkbenchiar

IAR preprocessor: include a tons of path


I need to add in iar's preprocessor a huge amount of paths! Every path has a lot of subfolder and so on. I dont want to do it manually because projects i am working on are very huges and the struct of the folders may vary over time! There is a method to automatically includes all the subfolder in a project? i am using iar 7.80

Thanks you very much


Solution

  • I'm not aware of project options to include subfolders of include paths with IAR.

    A few alternatives to using the project options dialog:

    1. Edit the *.ewp file

    If you search for CCIncludePath2, you'll find entries like this

    <option>
        <name>CCIncludePath2</name>
        <state>$PROJ_DIR$\..\include</state>
    </option>
    

    This means you can keep/generate a list of include paths and insert it relatively easily.

    2. Use subfolders in #include statements

    If you have your headers in a structure like this:

    include
    include/library1
    include/library1/componentX
    include/library1/componentX/buffer.h
    

    If you write in your code

    #include "library1/componentX/buffer.h"
    

    Rather than

    #include "buffer.h"
    

    You can configure IAR with an include path of include, but don't need include/library1/componentX. And it means that if there's another buffer.h in your include paths, there is no ambiguity.

    I prefer the second option, but it has limitations: If the files with the #include directives aren't within your control, you still have to specify each include path. It also offer the benefit that if you were to change the include folder structure, you can easily do a replace-in-files on the affected headers. The first option is not as elegant, but it can also be used where you can't change the files with the #include directives.