Author Topic: anonymous unions problem  (Read 1099 times)

davehohl

  • Senior Community Member
  • Posts: 270
  • Hero Points: 25
anonymous unions problem
« 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);
};

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2364
  • Hero Points: 319
Re: anonymous unions problem
« Reply #1 on: October 27, 2015, 09:04:38 pm »
Reproduced.  This one may have to go into a hot fix or the first patch.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2364
  • Hero Points: 319
Re: anonymous unions problem
« Reply #2 on: October 29, 2015, 04:31:20 pm »
This will be fixed in RC4.  You will need to rebuild your tag file.

davehohl

  • Senior Community Member
  • Posts: 270
  • Hero Points: 25
Re: anonymous unions problem
« Reply #3 on: October 29, 2015, 04:33:12 pm »
Great! Thanks, Dennis.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2364
  • Hero Points: 319
Re: anonymous unions problem
« Reply #4 on: October 29, 2015, 04:40:28 pm »
Hero point for the excellent example.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4176
  • Hero Points: 300
Re: anonymous unions problem
« Reply #5 on: October 30, 2015, 03:01:02 pm »
Please try RC 4

davehohl

  • Senior Community Member
  • Posts: 270
  • Hero Points: 25
Re: anonymous unions problem
« Reply #6 on: October 30, 2015, 03:31:27 pm »
This is indeed fixed in RC4. Thanks!