Thread: Enumeration question

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    42

    Enumeration question

    Hi guys. I try to explain this as best I can. Here is the situation: I have a microprocessor app and programming software for the micro, with identical memory mapping.

    In my programming software, there is form with indices 0, 1, 2, casted to an enum

    Code:
    enum
    {
    0, X
    1, Y
    2, Z
    }
    And then the parameter gets written to the processor memory.

    However, by accident, in the embedded code the enum was accidently defined as

    Code:
    enum
    {
    0, Z
    1, Y
    2, X
    }
    Here is whats happening: If I program X or Z to the embedded app and read it in my embedded app, both are seen as '0'. Y is seen as '1' as expected. Why is the underlying reason for this? C++ seems to be handling enums differently than i thought.
    Last edited by Link_26; 05-25-2011 at 10:07 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I note that your example code is actually syntactically invalid. Anyway, maybe someone with embedded programming knowledge can explain everything given just this information, but to me, you'll need to elaborate on:
    Quote Originally Posted by Link_26
    If I program X or Z to the embedded app and read it in my embedded app, both are seen as '0'.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enumeration Question
    By Marth_01 in forum C Programming
    Replies: 14
    Last Post: 11-06-2008, 11:00 AM
  2. enumeration design question
    By l2u in forum C++ Programming
    Replies: 17
    Last Post: 04-14-2008, 09:35 AM
  3. Enumeration
    By webren in forum C++ Programming
    Replies: 5
    Last Post: 04-10-2005, 02:47 PM
  4. enumeration question
    By jerrykelleyjr in forum C++ Programming
    Replies: 14
    Last Post: 12-17-2004, 11:59 AM
  5. Enumeration question?
    By cheesehead in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2001, 06:31 PM