Author Topic: anonymous unions problem  (Read 5055 times)

davehohl

  • Senior Community Member
  • Posts: 271
  • Hero Points: 27
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

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
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

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
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: 271
  • Hero Points: 27
Re: anonymous unions problem
« Reply #3 on: October 29, 2015, 04:33:12 PM »
Great! Thanks, Dennis.

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
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: 6864
  • Hero Points: 528
Re: anonymous unions problem
« Reply #5 on: October 30, 2015, 03:01:02 PM »
Please try RC 4

davehohl

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