473,327 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

typedef enum dilemma

15
Hi all gurus!

a little help here...
Expand|Select|Wrap|Line Numbers
  1. /* Common.h file */
  2. /*
  3. ** Media major and minor types
  4. */
  5. typedef enum
  6. {
  7.     VBMTYPE_UNKNOWN = 0,
  8.     VBMTYPE_AUDIO   = 1,
  9.     VBMTYPE_VIDEO   = 2
  10. }
  11. VBMTYPE;
  12.  
  13. /* console cpp file */
  14. int main(array<System::String ^> ^args)
  15. {
  16.     VBMTYPE _type = VBMTYPE::VBMTYPE_UNKNOWN;
  17.  
  18.     if(_type==VBMTYPE::VBMTYPE_UNKNOWN)
  19.     {
  20.         _type = VBMTYPE::VBMTYPE_VIDEO;
  21.     }
  22.  
  23.  
  24.     Console::ReadLine();
  25.         return 0;
  26. }
  27.  
but the problem is _type value is always <undefined value>.
How can i set the value then?
Im using C++/CLI anyway.

regards,
gudguy
Sep 14 '07 #1
7 20581
arnaudk
424 256MB
An enum is not a class and VBMTYPE is not a namespace, use

VBMTYPE _type = VBMTYPE_UNKNOWN;
Sep 14 '07 #2
gudguy
15
An enum is not a class and VBMTYPE is not a namespace, use

VBMTYPE _type = VBMTYPE_UNKNOWN;

Thanks arnaudk.

I tried your suggestion but still it gives me <undefined value>. For C++/CLI "enum class" i can assign a value, but for a "typedef enum" in native C++ it doesn't work.
Sep 17 '07 #3
gpraghuram
1,275 Expert 1GB
Thanks arnaudk.

I tried your suggestion but still it gives me <undefined value>. For C++/CLI "enum class" i can assign a value, but for a "typedef enum" in native C++ it doesn't work.

Hi ,
i changed it like this and it is compiling OK without issues using g++
Expand|Select|Wrap|Line Numbers
  1. /* Common.h file */
  2. /*
  3. ** Media major and minor types
  4. */
  5. typedef enum
  6. {
  7.     VBMTYPE_UNKNOWN = 0,
  8.     VBMTYPE_AUDIO   = 1,
  9.     VBMTYPE_VIDEO   = 2
  10. }VBMTYPE;
  11.  
  12. /* console cpp file */
  13. int main()
  14. {
  15.     VBMTYPE _type = VBMTYPE_UNKNOWN;
  16.     if(_type==VBMTYPE_UNKNOWN)
  17.     {
  18.         _type = VBMTYPE_VIDEO;
  19.     }
  20.  
  21.  
  22.         return 0;
  23. }
  24.  
Thanks
Raghuram
Sep 17 '07 #4
gudguy
15
Hi ,
i changed it like this and it is compiling OK without issues using g++
Expand|Select|Wrap|Line Numbers
  1. /* Common.h file */
  2. /*
  3. ** Media major and minor types
  4. */
  5. typedef enum
  6. {
  7.     VBMTYPE_UNKNOWN = 0,
  8.     VBMTYPE_AUDIO   = 1,
  9.     VBMTYPE_VIDEO   = 2
  10. }VBMTYPE;
  11.  
  12. /* console cpp file */
  13. int main()
  14. {
  15.     VBMTYPE _type = VBMTYPE_UNKNOWN;
  16.     if(_type==VBMTYPE_UNKNOWN)
  17.     {
  18.         _type = VBMTYPE_VIDEO;
  19.     }
  20.  
  21.  
  22.         return 0;
  23. }
  24.  
Thanks
Raghuram
Hi Raghuram,

The code I posted is compiling just fine as well. My problem is when I step through the code the line "VBMTYPE _type = VBMTYPE_UNKNOWN;" gives <undefined value> for _type. Even the line " _type = VBMTYPE_VIDEO;" or other values (member of VBMTYPE) gives <undefined value>. Not sure if this is native C++ behavior (can do assign externally but internally it has no meaning).

Regards,
Norman
Sep 18 '07 #5
gpraghuram
1,275 Expert 1GB
Hi Raghuram,

The code I posted is compiling just fine as well. My problem is when I step through the code the line "VBMTYPE _type = VBMTYPE_UNKNOWN;" gives <undefined value> for _type. Even the line " _type = VBMTYPE_VIDEO;" or other values (member of VBMTYPE) gives <undefined value>. Not sure if this is native C++ behavior (can do assign externally but internally it has no meaning).

Regards,
Norman
Hi,
I tried debugging the code which i posted and it showed this

16 {
(gdb) n
17 VBMTYPE _type = VBMTYPE_UNKNOWN;
(gdb) n
18 if(_type==VBMTYPE_UNKNOWN)
(gdb) p _type ///Trying to print here.
$1 = VBMTYPE_UNKNOWN
(gdb) where
#0 main () at a.cpp:18
(gdb) x _type
0x0: Cannot access memory at address 0x0

II think you cant access the value of a enum in debugger.

Thanks
Raghuram
Sep 18 '07 #6
gudguy
15
Hi,
I tried debugging the code which i posted and it showed this

16 {
(gdb) n
17 VBMTYPE _type = VBMTYPE_UNKNOWN;
(gdb) n
18 if(_type==VBMTYPE_UNKNOWN)
(gdb) p _type ///Trying to print here.
$1 = VBMTYPE_UNKNOWN
(gdb) where
#0 main () at a.cpp:18
(gdb) x _type
0x0: Cannot access memory at address 0x0

II think you cant access the value of a enum in debugger.

Thanks
Raghuram
Hi Raghuram,

Thanks for the investigation. So its only happening for a native "typedef enum"? Because for "enum class" in C++/CLI it is fine.

Regards,
gudguy
Sep 18 '07 #7
nbn
1
You can add a watch for the variable and edit the variable name like this:

Watch Window:
myVariable <undefined value> MY_ENUM

cast the variable in the watch window to see a value:

Watch Window:
(int)myVariable 5 int


the MSDN forums yielded this suggestion:
http://forums.microsoft.com/MSDN/Sho...78305&SiteID=1
Mar 11 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Fao | last post by:
Hi, I am in my first year of C++ in college and my professor wants me to Write a Program with multiple functions,to input two sets of user-defined data types: One type named 'Sign' declared by...
4
by: Chris | last post by:
I've lurked around long enough... Time to interract =) I'm trying to make sense of the following. I can't quite wrap my head around what this is actually doing: ------------- typedef enum {...
30
by: stephen henry | last post by:
Hi all, I have a question that I'm having difficulty answering. If I have a struct: typedef struct my_struct_tag{ struct my_other_struct *other; } my_struct_tag
13
by: Martin | last post by:
This post asks two questions, which I've illustrated in one C source file (see below), which clean compiles on my GNU compiler. 1. In K&R2, Section A8.9 it says "Declarations whose storage class...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
10
by: =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post by:
I came over this code which puzzled me. Isn't the enum supposed to have an identifier? enum { BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ BT_OPEN, BT_BOUND,...
4
by: msukumarbabu | last post by:
Hi all, What will be difference between "typedef enum" and "enum". or difference between “typedef structure" and "structure" I am going through some code. in that some place they are using...
3
by: wongjoekmeu | last post by:
Hello all, I was wondering what the differences are between these two things: 1) enum color { RED, BLUE }; and 2) typedef enum { RED, BLUE } color; Is there a difference anyway ? Why...
9
by: C_guy | last post by:
I noticed that typedef enum _myEnum { enum1 = 0, enum2, enum3, .....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.