Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do MC-3020 enumerations map to #defines?

enumerations map mc-3020
0
Posted

Why do MC-3020 enumerations map to #defines?

0

Enumeration support in ANSI C is very weak. Name spacing is absent. Consider enum rock { red = 1 }; enum stone { red = 2 }; … material_color = red; Since enum is not scoped by a C++(ish) class, and C has no namespacing, there is no way for a C compiler to distinguish which “red” to assign to material_color. Note that these declarations may live in separate include files. Thus, MC-3020 uses “long winded” namespacing of #define to avoid the C language weakness. Another weakness lies in the lack of control over the storage allocated to variables declared to be of enumerated type. In resource constrained environments (say an 8-bit micro), we would like our enums to take up something less than an integer of storage.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123