www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - structs within unions bug ?

reply Charlie <Charlie_member pathlink.com> writes:
import win32.ansi.windows;


struct EventArgs
{
union
{
struct TextSelectionArgs{
int selIndex;
char [] selText;
};

struct IndexSelectionArgs {
int selIndex;
int subSelIndex;
};

struct CoordinateArgs {
int xPos;
int yPos;
int vKey;
};

}

static EventArgs create(WPARAM w, LPARAM l )
{
EventArgs x;
x.wparam = w;
x.lparam = l;

return x;
}

WPARAM wparam;
LPARAM lparam;			

}

int main () {

EventArgs args;
args.CoordinateArgs.xPos = 21;
args.CoordinateArgs.yPos = 21;

return 1;


}


$dmd foo.d -I/dmd/include
foo.d(44): no property 'CoordinateArgs' for type 'EventArgs'



Im not sure if this a bug or not, should I be able to do this ?

Charlie
Jun 18 2004
next sibling parent Charlie <Charlie_member pathlink.com> writes:
Here it is in readable format
http://www.noidea128.org/cgi-bin/framesource.cgi?id=5649&type=html

C

In article <cb07es$o5s$1 digitaldaemon.com>, Charlie says...
import win32.ansi.windows;


struct EventArgs
{
union
{
struct TextSelectionArgs{
int selIndex;
char [] selText;
};

struct IndexSelectionArgs {
int selIndex;
int subSelIndex;
};

struct CoordinateArgs {
int xPos;
int yPos;
int vKey;
};

}

static EventArgs create(WPARAM w, LPARAM l )
{
EventArgs x;
x.wparam = w;
x.lparam = l;

return x;
}

WPARAM wparam;
LPARAM lparam;			

}

int main () {

EventArgs args;
args.CoordinateArgs.xPos = 21;
args.CoordinateArgs.yPos = 21;

return 1;


}


$dmd foo.d -I/dmd/include
foo.d(44): no property 'CoordinateArgs' for type 'EventArgs'



Im not sure if this a bug or not, should I be able to do this ?

Charlie

Jun 18 2004
prev sibling parent "Carlos Santander B." <carlos8294 msn.com> writes:
"Charlie" <Charlie_member pathlink.com> escribió en el mensaje
news:cb07es$o5s$1 digitaldaemon.com
|
| [code]
|

Change EventArgs to:

struct TextSelectionArgs{
    int selIndex;
    char [] selText;
};

struct IndexSelectionArgs {
    int selIndex;
    int subSelIndex;
};

struct CoordinateArgs {
    int xPos;
    int yPos;
    int vKey;
};

struct EventArgs
{
    union
    {
        TextSelectionArgs text;
        IndexSelectionArgs index;
        CoordinateArgs coor;
    }
    static EventArgs create(WPARAM w, LPARAM l )
    {
        EventArgs x;
        x.wparam = w;
        x.lparam = l;

        return x;
    }

    WPARAM wparam;
    LPARAM lparam;
}


| Im not sure if this a bug or not, should I be able to do this ?
|
| Charlie

I think that's the expected behavior.

-----------------------
Carlos Santander Bernal
Jun 19 2004