Jump to content

Why do Leadwerks have a "Button1" define/macro?


Guppy
 Share

Recommended Posts

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

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

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

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

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
};
}

Link to comment
Share on other sites

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 ;)

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...