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.

problem with include files



Hi

I have tried to re-arrange my project so that it will have config.h header file and device.h header file.

In config.h i define the current device compilation type and in device.h i define the device specific attributes.

The problem is that the changes i make in the config.h file affects only the device.h file (it doen't permeate to the source file which include the device.h file)

Is there any  restriction concerning doing such "include to include"?

thank you

Yaron

  • I forgot to mention, I am using  Version: 5.4.0.00091 

  • yaron apel said:

    The problem is that the changes i make in the config.h file affects only the device.h file (it doen't permeate to the source file which include the device.h file)

    Could you please provide an example that shows what your #includes look like in all your header and source files so we can better understand your question?

  • Hi

    here is an example:

    config.h:

    #define DEVICE_0 (0)
    #define DEVICE_1 (1)
    #define DEVICE_2 (2)

    #define DEVICE DEVICE_1

    device.h:

    #include "config.h"

    #if (DEVICE == DEVICE_1)
    #define ATTR_ENABLE (1)
    #else
    #define ATTR_ENABLE (0)
    #endif

    main.c:

    #include "device.h"

    int main(void) {
    int i;

    #if ATTR_ENABLE
    i = 1;
    #else
    i = 2;
    #endif

    return i;
    }

    the problem is that when i change the #define DEVICE DEVICE_1 to DEVICE_2  the compilation of main.c doesn't change. 

  • Thank you for providing the test case, I can reproduce the behavior. As you noted, a change in config.h updates macro expansions in device.h, but doesn't update them in main.c. I will submit a bug report for the developers to take a look at this, but in the meantime, a workaround is to manually rebuild the index by right-clicking on the project and going to Index->Rebuild.

  • FYI, the bug tracking # for this issue is SDSCM00047490.

  • Hi

    thanks for the answer.

    can you please verify what does index-rebuild action do? 

    can i somehow use this option from command line?

  • The indexer comes with the Eclipse CDT and is reponsible for parsing tthe source code and creating an index(database) for fast lookups and for things like search, navigation, finding definition/declaration etc. The CCS online help has some more information on it.

    I don't believe you can rebuild the index from command line.