SlickEdit Community

Archived Beta Discussions => SlickEdit 201x Beta Discussions => SlickEdit 2015 v20 Beta Discussion => Topic started by: davehohl on October 27, 2015, 08:23:51 PM

Title: anonymous unions problem
Post by: davehohl on October 27, 2015, 08:23:51 PM
Version 20 seems to get confused by anonymous unions. For version 20 the symbol coloring for the member function below shows params.cumulativeTestCount in red (unknown symbol) and if I hover over it I get "Symbol color:symbol not found."

Version 19 handles it fine.

I did already retag the project for version 20.

Here is the function (in .cpp file):

void ConfigParams::setCumulativeTestCount(U32 count)
{
    params.cumulativeTestCount = count;
    updateCrc();
    (void)writeToEeprom();
}

Here is the class definition (in .h file):

class ConfigParams
{
    friend S16 debugFunctions(void);

    public:
        ConfigParams(void);
        ~ConfigParams(void);

        U32 getCumulativeTestCount(void) const;
        U32 incrementCumulativeTestCount(void);
        void setSerialNumber(const Char *serNum);
        void getSerialNumber(Char *serNum) const;

        static bool initialize(void);
        bool crcIsValid(void) const;
        bool readFromEeprom(void);
       
    private:
        union
        {
            struct
            {
                U32 cumulativeTestCount;
                Char serialNumber[SERIAL_NUMBER_LENGTH];
            } params;

            // raw element ensures that the size of the class is a multiple
            // of 4 bytes, with the CRC in the last 2 bytes (assuming
            // DEVICE_CONFIG_EEPROM_BYTES is a multiple of 4 bytes)
            U8 raw[DEVICE_CONFIG_EEPROM_BYTES - sizeof(U32)];
        };
        U16 pad;    // needed to align crc in last two bytes of the block
        U16 crc;

        void updateCrc(void);
        bool writeToEeprom(void) const;
        void setCumulativeTestCount(U32 count);
};
Title: Re: anonymous unions problem
Post by: Dennis on October 27, 2015, 09:04:38 PM
Reproduced.  This one may have to go into a hot fix or the first patch.
Title: Re: anonymous unions problem
Post by: Dennis on October 29, 2015, 04:31:20 PM
This will be fixed in RC4.  You will need to rebuild your tag file.
Title: Re: anonymous unions problem
Post by: davehohl on October 29, 2015, 04:33:12 PM
Great! Thanks, Dennis.
Title: Re: anonymous unions problem
Post by: Dennis on October 29, 2015, 04:40:28 PM
Hero point for the excellent example.
Title: Re: anonymous unions problem
Post by: Clark on October 30, 2015, 03:01:02 PM
Please try RC 4
Title: Re: anonymous unions problem
Post by: davehohl on October 30, 2015, 03:31:27 PM
This is indeed fixed in RC4. Thanks!