About Store Forum Documentation Contact



Post Reply 
UNION keyword
Author Message
Rubeus Offline
Member

Post: #1
UNION keyword
A union would be perfect for what I'm trying to do, but judging by the addition of the UNION keyword in the editor and it's comment, it looks like unions are not supported on non-windows platforms-is this correct? Does Esenthel just create all the UNION_ELMs as regular variables if union is not supported on the platform?

Anyways, in the spirit of being multi-platform friendly, I attempted to use UNION( UNION_ELM(x) ), but was unable to compile. If I copy and paste from the UNION in Shape into a struct in 1 - Basic App, it still gives compiler errors. Am I missing something?
09-13-2013 12:29 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: UNION keyword
'union' will not work on GCC if the members have constructors, if they don't have them then you can use 'union', otherwise you can try doing 'UNION' which will do 'union' on Windows, and list elements separately on other platforms.

Is the compile error only in Esenthel Code Editor, or when you try do to that in Visual Studio as a header too?

Please paste your code
09-13-2013 02:28 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #3
RE: UNION keyword
(09-13-2013 02:28 AM)Esenthel Wrote:  'union' will not work on GCC if the members have constructors, if they don't have them then you can use 'union', otherwise you can try doing 'UNION' which will do 'union' on Windows, and list elements separately on other platforms.

Is the compile error only in Esenthel Code Editor, or when you try do to that in Visual Studio as a header too?

Please paste your code

I can use union if I don't have constructors-got it.

Code editor code:
Code:
/******************************************************************************/
void InitPre() // init before engine inits
{ EE_INIT(); }
/******************************************************************************/
bool Init() // initialize after engine is ready
{ return true; }
/******************************************************************************/
void Shut() // shut down at exit
{ }
/******************************************************************************/
bool Update() // main updating
{
   if(Kb.bp(KB_ESC))return false; // exit if escape on the keyboard pressed
   return true;                   // continue
}
/******************************************************************************/
void Draw() // main drawing
{
   D.clear(TURQ); // clear screen to turquoise color
   D.text (0, 0, "Hello to Esenthel Engine 2.0 !"); // display text at 0, 0 screen coordinates
}
/******************************************************************************/
struct test
{
   UNION
   (
      UNION_ELM(Vec     point  ;)
      UNION_ELM(Edge    edge   ;)
   )
}

What comes up in VS when I compile:
Code:
struct test
{
   U;;;;;;;;;;;;;;NION
   (
      UNION_ELM(Vec     point  ;)
      UNION_ELM(Edge    edge   ;)
   )
};
09-13-2013 02:02 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: UNION keyword
Thanks, I'll investigate this.
In the meantime you can try using 'Shape' which is an already union for engine supported shapes.
09-15-2013 12:34 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #5
RE: UNION keyword
Thank you very much for reporting the issue!
I've just fixed it and will work ok in next release.
09-23-2013 07:49 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #6
RE: UNION keyword
Thank you again, as usual.
09-24-2013 08:48 AM
Find all posts by this user Quote this message in a reply
Post Reply