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.

include dependency hell

Genius 5910 points

For my application I need to rewrite/modify the library code. and now I'm in a include dependency hell. To solve this I split the struct define and functions definitions. But that doesn't work very well. Is seems like that include the same file at multiple levels gives problems.

 This part I don't understand is.

If I include the correct include file I still got the same errors:

#include "sw/modules/enc/src/32b/enc.h"

 in the beginning of the function. I still got the error message:

Description    Resource    Path    Location    Type
#20 identifier "ENC_Handle" is undefined    Servo_obj.h    /Servodriver    line 292    C/C++ Problem
#20 identifier "ENC_Obj" is undefined    Servo_obj.h    /Servodriver    line 293    C/C++ Problem

(Yes, both objects are in enc.h)

So Why is this?  The only thing I can think of is that _ENC_H_ is already defined only the includes information is lost?

Can Someone please explain.

Thanks!

Edit: Somehow #include "main_position.h"  seems toxic . strange, very strange.

  • Could you send me the files that you changed? I am trying to replicate the error. What I did to try it, it doesn't fail. I created a test_header.h with this:

    // **************************************************************************
    // the includes
    
    #include "sw/modules/enc/src/32b/enc.h"
    
    //! \brief Defines the Test object
    //!
    typedef struct _TEST_Obj_
    {
    	uint32_t    var1;
    	uint32_t    var2;
    	uint32_t    var3;
    	uint32_t    var4;
        ENC_Handle  encHandle;
        ENC_Obj     enc;
    } TEST_Obj;
    
    //! \brief Handle
    //!
    typedef struct _TEST_Obj_ *TEST_Handle;

    Then in lab 13a in included:

    #include "test_header.h"

    Then I declared the object and handle:

    TEST_Obj testObj;
    TEST_Handle testHandle;

    And it builds ok. Send me the files I can use to replicate the issue please.

    -Jorge

  • The problem disappeared when I removed main_position.h from my whole (big) project. And only added the needed included for each file. So problem and solution are not related. 

    I think there is a maximal  time you can call a include file. I also experienced the same problem If you call a include file that includes the file that it  included from. As the preprocessor breaks this loop the include #define is not cleared as it seems.  So when this include file is called again from an other called include file from the same source.The include define is stilled defined but the include data is lost..

    Sorry, I can't give you a working example of the problem.