What is this thing in my STRUCT?



  • Hi Qt's,

    I did the search and even reread chapter 8 of "The C++ Programming Language".

    So I am trying to get up to speed on Qt and C++ and came across this little gem in an example:

    //Structure for the response to the QUERY_EXTENDED_INFO command
        union ExtendedQueryInfo
        {
            unsigned char command;
            struct
            {
                unsigned char command;
                uint16_t bootloaderVersion;
                uint16_t applicationVersion;
                uint32_t signatureAddress;
                uint16_t signatureValue;
                uint32_t erasePageSize;
                unsigned char config1LMask;
                unsigned char config1HMask;
                unsigned char config2LMask;
                unsigned char config2HMask;
                unsigned char config3LMask;
                unsigned char config3HMask;
                unsigned char config4LMask;
                unsigned char config4HMask;
                unsigned char config5LMask;
                unsigned char config5HMask;
                unsigned char config6LMask;
                unsigned char config6HMask;
                unsigned char config7LMask;
                unsigned char config7HMask;
                unsigned char pad[USB_PACKET_SIZE_WITH_REPORT_ID - 29];
            }PIC18;
            struct
            {
                unsigned char command;
                uint16_t bootloaderVersion;
                uint16_t applicationVersion;
                uint32_t signatureAddress;
                uint16_t signatureValue;
                uint32_t erasePageSize;
                uint16_t configxxMask...
                unsigned char pad[USB_PACKET_SIZE_WITH_REPORT_ID - XX];
            }PIC24;
        };
    

    Can someone explain the purpose of the PIC18 and PIC24 at the end of those 2 struct's?

    Regards,

    Chris


  • Moderators

     struct
             {
                 unsigned char command;
                 uint16_t bootloaderVersion;
                 uint16_t applicationVersion;
                 uint32_t signatureAddress;
                 uint16_t signatureValue;
                 uint32_t erasePageSize;
                 uint16_t configxxMask...
                 unsigned char pad[USB_PACKET_SIZE_WITH_REPORT_ID - XX];
             } PIC24;
    

    This defines an anonymous structure and declares a variable of this type named "PIC24" .


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That's rather a general C/C++ question unrelated to Qt but anyway, here you have the complete explanation



  • @SGaist thanks for the warm reception.

    Thanks for the link. I have written firmware in C and some desktop apps in C#. And since I'm no expert in either, moving to C++ in Qt it becomes a little unclear what code related items are strictly C++ and which are part of the Qt IDE.

    I hope to get it sorted without committing to many forum faux pas.

    Best regards,

    Chris


  • Lifetime Qt Champion

    Don't worry for that, you won't be eaten ;)

    I've forgotten that there's also the C++ Guru sub forum when you have questions that are more C++ oriented

    Happy coding !


Log in to reply
 

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