Compilation issue: aggregate 's_toto reply' has incomplete type and cannot be defined



  • Hello everyone ;-)

    I am trying to compile this code but I have very strange issue:
    erreur : aggregate 's_toto reply' has incomplete type and cannot be defined

    It look's like generate a structure which have a incomplete type. I didn't know that thing exist ^^.

    The problem occur when I try to declare "reply" of "s_toto" type which is a structure declared in "MessagesFromClientToServer.h"

    This is my code:
    Client.cpp:

    Client::Client(QTcpSocket * p_client, QObject * parent) : QThread(parent)
    {
        // Declaration
        s_toto reply;
    }
    

    Client.h include "MessagesFromClientToServer.h"

    MessagesFromClientToServer.h:

    // Message from Server to Client to reply the request
    struct {
        unsigned int magic;
        unsigned int type;
        unsigned int server_version;
        unsigned int min_client_version;
        bool client_version_OK;
        bool client_pseudo_OK;
        bool nothing;
        unsigned int stop;
    } toto;
    typedef struct toto s_toto;
    

    My compiler error:

    client.cpp:12:12: error: aggregate 's_toto reply' has incomplete type and cannot be defined s_toto reply;
    

    Have you an idea how to fix it ?

    Thank you in advance ;-)


  • Qt Champions 2016

    @iTom said in Compilation issue: aggregate 's_toto reply' has incomplete type and cannot be defined:

    Have you an idea how to fix it ?

    My advice is to give a name to your structure. Something like this:

    struct toto {
        // ...
    };
    

  • Moderators

    @iTom To add to @kshegunov : did you include MessagesFromClientToServer.h header file where you're trying to use it?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.