This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430F5438A: Not able to include header files in Compiler Include Options

Part Number: MSP430F5438A

Tool/software: Code Composer Studio

Hi,

I have created Src/Driver/I2C folder in my project and created i2c_driver.c and i2c_driver.h files in that.

I have created Src/Test/I2C folder in my project and created test_i2c.c and test_i2c.h files in that.

To use the driver file i2c_driver.c, I would like to include i2c_driver.h in test_i2c.c. 

One way to do that is, add #include "../../Driver/I2C/i2c_driver.h" in test_i2c.c

Another way I am trying is including the Src/Driver/I2C folder in the Include Options of the Compiler in the Project Properties and add #include "i2c_driver.h" in test_i2c.c directly. But the compiler is throwing an error saying "#1965 open source file "i2c_driver.h".

I would like to know why I am getting the error when I have already included the folder containing the driver header file.

Is there a better way to do it?

To sum up my problem, I am posting a screenshot of my project below:

  • I usually use a slightly different variable but what you have should work.

    I have created a project with the same basic directory structure:

    I then added the same include search path.  Note that when you put your mouse over the ... it will display the full path so that you can check if it is correct.

    Normally I use a variable more like this as that is the way it get inserted when I click the workspace button and select the folder under the project.

    But it really shouldn't matter as if I add the same variable as you it works for me.  

    One thing I noticed in your screen capture is the little wrench icon on some of the folders such as Src.  This means that the folder has file specific build options set.  I am concerned that the include path is not being used when building the source file has you have overridden the build options for the files in that folder.  If the include path was added to the project after that then it would not be used when building files that are under that folder.

    There are a couple quick ways you can check that.

    1. Look at the output in the console when building test_i2c.c  I believe you will note see a --include_path that is the location of the header file.
    2. Right click on test_i2c.c in the Project Explorer and select properties.  Inspect the paths listed under Include Options.  It is likely not there.

    Regards,

    John

  • Hi John,

    I had enabled ccs in-built MISRA check on few of the folders, that's why there was that wrench icon. However, I cannot enable MISRA on whole project as it will start giving errors for all TI header files. Anyways I disabled the MISRA check and the problem of "not able to find header file" got fixed.

    Can I ask you, what do you men when you mentioned "I usually use a slightly different variable but what you have should work."?

    I have another query to ask you. How to include header files neatly? If I start adding every individual header file in the include options, then definitely the list can gover hundred to few hundreds. Can you suggest me some other way to do it?

    Thanks and Regards,
    Ankit
  • Ankit,

    The slightly different variable that I used was ${workspace_loc:/${ProjName}/Src/Driver/I2C} vs the ${PROJECT_ROOT}/Scr/Driver/I2C that you used. I used the first one as that is how CCS/Eclipse will insert the variable when I click on the Add button to add a path and then click on the Workspace button and browse to the folder that I want. Either one will work fine.

    If the header files are spread out in many different folders you can end up with a lot of include paths to add to the build options. Note that you don't add for every file just every location where include files are located.

    If you want to reduce the number of paths what you can do is add some common base paths as the include path and then adjust your #include statements to include some relative path information.

    For example in this case I could have ${PROJECT_ROOT}/Scr/Driver/ as my include path and then change my the #include "i2c_driver.h" to be #include <I2C/i2c_driver.h>

    Then for other files I could use #include <SPI/nameofheader.h>

    Regards,
    John
  • Thanks a lot John for the cue.

    The way you have suggested would really help me ease my problems. 

    Another thing I wanted to ask you was, is there a way where I use a makefile in every directory and subdirectory; where a makefile in a directory will compile all the files and sub-directories recursively using the subdirectory file. For e.g. there is a makefile in

    For e.g. there is a makefile in I2C folder, which compiles i2c_driver.c and another makefile in SPI folder tp compile spi_driver.c. One directory up, Drivers folder will have a makefile which will collect the results from the makefiles of the respective sub-directories and compiles its own source files as well. And one directory up, likewise. 

    Is that feasible? Any illustration to do it?

    Thanks and Regards,

    Ankit

  • Ankit,

    I suppose you could do that but you would need to do it manually. CCS/Eclipse doesn't have an automatically way of doing it. Thus you would have to create and maintain all of the makefiles yourself.

    Regards,
    John
  • Thanks a lot John :)