Enumeration question

This is a discussion on Enumeration question within the C++ Programming forums, part of the General Programming Boards category; Hi guys. I try to explain this as best I can. Here is the situation: I have a microprocessor app ...

  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
    20,955
    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'.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 10: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, 10:59 AM
  5. Enumeration question?
    By cheesehead in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2001, 05:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21