LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is a enum stored?

Hi all,

 

I am kind of curious about how an enum is stored.  If I choose U8 for my enum, I know that I need at least 8 bits to store the number.  Where is the string portion of the enum stored?  And how is it stored?

 

I tried to do a U32 type cast on the U8 enum, and I found what I didn't expect.  I found that the original 8 bits became the MSB of the new 32 bits, instead of the LSB.  Why is that?  See attached. 

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 6
(3,673 Views)
To get what you expect the Type Cast to do, convert the U8 to U32.  You told LV to look in memory where the U8 is stored and treat it as a U32,  the first 8 bits are as expected, the other 24 0's are just values from never-never land in memory.
0 Kudos
Message 2 of 6
(3,664 Views)

In this thread Greg McKaskle talks about enums.

 

This explains how the type descriptor is formatted.

 

And this used to work for pulling out the strings.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 6
(3,653 Views)

Hi Ben,

 

Good information.  How do you get the type description information in hex from in LV? 


Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 4 of 6
(3,640 Views)

"Flatten to string" and choose (pop-up) the old version. The new thinks we don't need to know that anymore. Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 6
(3,628 Views)

Ben wrote:

"Flatten to string" and choose (pop-up) the old version. The new thinks we don't need to know that anymore. Smiley Wink


Fortunately we now have modern tools that can take an enum as an input and give us the list of strings: vi.lib\utility\VariantDataType\GetNumericInfo.vi

0 Kudos
Message 6 of 6
(3,582 Views)