Guppy Posted September 12, 2014 Share Posted September 12, 2014 This one has been driving me nuts, the below code fails to build in leadwerks namespace MyGUI{ enum Enum { Button0 = 0, Button1, Button2, Button3, Button4, Button5, Button6, Button7, MAX }; } I finally tracked it down to Button1 being #defined as 1 - presumably somewhere in the leadwerks linked library as I certainly haven't made that it and MyGUI builds just fine. I've worked around it so far by simply commenting out buttons 1-7 and setting MAX to 8 explicitly - but now I need to pass Enum:Button1 so I kind of need it. I can do #undef Button1 #undef Button2 #undef Button3 #undef Button4 #undef Button5 In this header file and it also solves the problem - but I'm not sure if that will screw something up for LE, or even why those defines exists in the first place Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Rick Posted September 12, 2014 Share Posted September 12, 2014 If LE's Button1 is wrapped in the Leadwerks namespace then it shouldn't matter. That's the whole point of a namespace right? If it's not then I'd say that's a bug. Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 12, 2014 Author Share Posted September 12, 2014 I don't believe you can namespace defines? But yes it would make more sense if it was Leadwerks::Button1 or even better Leadwers::MouseButtons:Button1 as it is it seems to be just #define Button1 1 [...] #define Button5 5 Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Vulcan Posted September 12, 2014 Share Posted September 12, 2014 If you got a GUI class then you could use an enum class inside your class. Use it like this: MyClass::MyEnum::GREEN. If you want to use it as an ordinary enum you could use C-style casting to int. class MyClass { public: MyClass(); virtual ~MyClass(); enum class MyEnum { NONE = 0, RED, GREEN, BLUE }; } Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 12, 2014 Author Share Posted September 12, 2014 I don't think you understand the issue vulcan the problem is that Button1 has a #define to relate it to your example, Try adding #define GREEN 2 and see if it will compile Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Vulcan Posted September 13, 2014 Share Posted September 13, 2014 ohh I see, I really should have paid more attention to the title Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.