"dereferencing pointer to incomplete type" error while compiling on VxWorks.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tejesh
    New Member
    • Mar 2008
    • 3

    "dereferencing pointer to incomplete type" error while compiling on VxWorks.

    I am trying to compile the following code

    int backend_sm_run( struct interface_data *ctx)
    {
    xsup_assert((ct x != NULL), "ctx != NULL", TRUE);

    xsup_assert((ct x->statemachine != NULL), "ctx->statemachine != NULL",
    TRUE);

    backend_sm_chec k_globals(check );

    switch (ctx->statemachine->beCurState)
    {
    case INITIALIZE:
    // We should *NEVER* get here!
    backend_sm_do_i nitialize(ctx);
    break;

    case IDLE:
    backend_sm_do_i dle(ctx);
    break;

    case REQUEST:
    backend_sm_do_r equest(ctx);
    break;

    case RESPONSE:
    backend_sm_do_r esponse(ctx);
    break;

    }

    return XENONE;
    }

    "dereferenc ing pointer to incomplete type" error is thrown at lines
    xsup_assert((ct x->statemachine != NULL), "ctx->statemachine != NULL",
    TRUE);
    and

    switch (ctx->statemachine->beCurState).

    interface_data structure is defined in "profile.h" which is been included.

    Pls reply for any clarifications/suggestions
  • Ambrish Kinariwala
    New Member
    • Mar 2008
    • 6

    #2
    Can you please include the data structure of type ctx in your post. According to my interpretation "incomplete type" means compiler know that ctx is of type struct but does not know about the members of the type struct.

    Please check whether the file profile.h has actual declaration of struct ctx.
    For example struct { int x; } ctx; ---> This is the actual declaration of the struct.

    What I suspect is that the file profile.h just has a stuct tag defined and thats why it does not know about the members of the actual struct ctx.
    For example Profile.h just has the definition of tag such as stuct xxx ctx;

    If a specifier with a tag but without a list (i.e the declaration) appears when the tag is not declared, an incomplete type is returned by the compiler.
    I suggest you include the declaration of struct ctx in profile.h.

    I hope this helps.

    Thanks.
    Ambrish Kinariwala

    Comment

    • tejesh
      New Member
      • Mar 2008
      • 3

      #3
      Originally posted by Ambrish Kinariwala
      Can you please include the data structure of type ctx in your post. According to my interpretation "incomplete type" means compiler know that ctx is of type struct but does not know about the members of the type struct.

      Please check whether the file profile.h has actual declaration of struct ctx.
      For example struct { int x; } ctx; ---> This is the actual declaration of the struct.

      What I suspect is that the file profile.h just has a stuct tag defined and thats why it does not know about the members of the actual struct ctx.
      For example Profile.h just has the definition of tag such as stuct xxx ctx;

      If a specifier with a tag but without a list (i.e the declaration) appears when the tag is not declared, an incomplete type is returned by the compiler.
      I suggest you include the declaration of struct ctx in profile.h.

      I hope this helps.

      Thanks.
      Ambrish Kinariwala



      Thank U Ambrish for the suggestion. I had suspected the same thing but the structure elements do exist. You can have a look at the structure and pls advice.
      "Profile.h" includes the following

      struct dot1x_state
      {
      /* These variables are per the 802.1x documentation.*/
      /* These are defined as constants, but don't have to be. We may want */
      /* the option of changing them in the future. */
      char authPeriod;
      char heldPeriod;
      char startPeriod;
      char maxStart;

      /* per 802.1x-REV-d11 section 8.2.2.1 */
      char authWhile;
      char aWhile;
      char heldWhile;
      char quietWhile;
      char reAuthWhen;
      char startWhen;

      /* per 802.1x-REV-d11 section 8.2.2.2 */
      char eapFail;
      char eapolEap;
      char eapSuccess;
      char keyAvailable;
      char keyDone;
      char keyRun;
      char keyTxEnabled;
      char portControl;
      char suppPortStatus;
      char portValid;
      char suppAbort;
      char suppFail;
      char suppStart;
      char suppSuccess;
      char suppTimeout;
      char initialize;
      char portEnabled;

      /* per 802.1x-REV-d11 section 8.2.11.1.1 */
      char eapRestart;
      char logoffSent;
      char sPortMode;
      char startCount;
      char userLogoff;

      /* per 802.1X-REV-d11 section 8.2.12.1.1 */
      char eapNoResp;
      char eapReq;
      char eapResp;

      /* per 802.1x-REV-d11 section 8.2.3.1.1 port timers */
      char tick;

      /* per 802.1x-REV-d11 section 8.2.7.1.1 Key recieve */
      char rxKey;

      /* This isn't in the spec, but is useful.*/
      char curState;
      char beCurState;
      char wpaCurState;
      char wpaLastState;

      /* This is to contain the last type of EAP packet we saw. It's only
      functional purpose is to allow us to give the user some sort of error
      message about what might be wrong with the connection. (i.e. If the
      last EAP message we got was a Request ID, and we get a TIMEOUT, it means
      we attempted to send a Response ID, and for some reason the AP ignored
      us.*/
      char lastEapType;

      /* Keep track of the key length that is used in dynamic WEP. (Basically,
      we want to know the shortest unicast and shortest broadcast keys the
      AP sent.) This servers no functional purpose, but will allow us to warn
      the user that some cards/drivers/APs are not happy using different length
      WEP keys.*/
      char unicastKeyLen;
      char broadcastKeyLen ;



      /* This contains the number of MIC failures the driver has reported.
      Once it reaches 2, we should enable countermeasures .*/
      char MICfailures;

      uint8_t replay_counter[8];
      };

      struct interface_data
      {
      char *intName; /* The name of this interface.*/


      char source_mac[6]; /* Source MAC address.*/
      char dest_mac[6]; /* Destination MAC address.*/

      char *cur_essid; /* The current SSID we are using.*/

      struct dot1x_state *statemachine; /* State machine info*/

      uint8_t *keyingMaterial ; /* Hold any keying material generated by
      an EAP type. Should be NULL if there
      isn't any!*/

      char keyingLength; /* Normal EAP methods will return 32 bytes
      of keying material. Goofy EAP methods
      like LEAP use less material.*/

      char *tempPassword; /* Temporary password.*/


      uint8_t sendframe[1520], recvframe[1520];
      int send_size, recv_size;
      } ;

      Comment

      • Ambrish Kinariwala
        New Member
        • Mar 2008
        • 6

        #4
        I would suggest to first find out where the definition of ctx is in your code base (where memory was allocated). Then try declaring that as extern at global level in your program and see the results.

        It seems you may have some scope issues. Make sure that the function you're running is in the inner scope of where the ctx is actually declared in .h file. Check to see in what order it compiles the files.

        I hope this helps.

        Ambrish Kinariwala

        Comment

        • tejesh
          New Member
          • Mar 2008
          • 3

          #5
          Originally posted by Ambrish Kinariwala
          I would suggest to first find out where the definition of ctx is in your code base (where memory was allocated). Then try declaring that as extern at global level in your program and see the results.

          It seems you may have some scope issues. Make sure that the function you're running is in the inner scope of where the ctx is actually declared in .h file. Check to see in what order it compiles the files.

          I hope this helps.

          Ambrish Kinariwala

          Thank U Ambrish for the advice. I included "extern struct interface_data *ctx;" in the file "profile.h" as ctx was not defined anywhere.
          Now there is no dereferencing error. Pls comment whether this is fine.

          Comment

          • Ambrish Kinariwala
            New Member
            • Mar 2008
            • 6

            #6
            That should be fine. You can even include the extern declaration in the source file.

            Thanks.
            Ambrish Kinariwala

            Comment

            Working...