request.h: size of unnamed array is negative

Hugh McMaster hugh.mcmaster at masterindexing.com
Sat Apr 13 22:40:01 CDT 2013


Am 13.04.2013 15:39, schrieb Hugh McMaster:
> I've been adding a new handler to Wine's server.  Unfortunately, I've run into a problem with C_ASSERT that I can't seem to resolve.
> 
> In server/request.h, I've added the following code:
> 
> C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_request, spi_workarea) == 16 );
> C_ASSERT( sizeof(struct get_desktop_workarea_request) == 16 );
> C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_reply, screen_x) == 4 );
> C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_reply, screen_y) == 4 );
> C_ASSERT( sizeof(struct get_desktop_workarea_reply) == 8 );
> 
> But the compiler ends with output errors, as in the following:
> 
> In file included from request.c:69:0:
> request.h:1527:1: error: size of unnamed array is negative
> request.h:1528:1: error: size of unnamed array is negative
> request.h:1529:1: error: size of unnamed array is negative
> request.h:1530:1: error: size of unnamed array is negative
> request.h:1531:1: error: size of unnamed array is negative
> 
> Each error represents the C_ASSERT code listed above.
> 
> I'm probably missing something obvious here. Can someone please offer any advice on resolving these errors?

>>we'd need more info like the actual struct get_desktop_workarea_request

Hallo André, I missed your response to the list.

This is what I have done.  Wine compiles perfectly if I uncomment the C_ASSERT lines. I note that Charles Davis said in another response that request.h should not be modified.

*** server/protocol.def ***
/* Retrieve the desktop workarea */
@REQ(get_desktop_workarea)
    RECT  spi_workarea;         /* values from SystemParametersInfo */
@REPLY
    int   screen_x;             /* screen dimensions without taskbar */
    int   screen_y;
@END

*** server/window.c ***
/* retrieve the desktop workarea */
DECL_HANDLER(get_desktop_workarea)
{
    RECT wa;
    wa = req->spi_workarea;
    int screen_w = wa.right;
    int screen_h = wa.bottom;
    reply->screen_x = screen_w;
    reply->screen_y = screen_h;
}

*** include/wine/server_protocol.h ***

struct get_desktop_workarea_request
{
    struct request_header __header;
    RECT  spi_workarea;
};
struct get_desktop_workarea_reply
{
    struct reply_header __header;
    int  screen_x;
    int  screen_y;
};

enum_request
{
    [snip]
    REQ_get_desktop_workarea,
    [snip]
}

generic_request
{
    [snip]
    struct get_desktop_workarea_request get_desktop_workarea_request;
    [snip]
}

generic_request
{
    [snip]
    struct get_desktop_workarea_reply get_desktop_workarea_reply;
    [snip]
}

*** server/request.h ***
DECL_HANDLER(get_desktop_workarea);

static const req_handler req_handlers[REQ_NB_REQUESTS] =
{
    [snip]
    (req_handler)req_get_desktop_workarea,
    [snip]
}
[snip]
C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_request, spi_workarea) == 16 );
C_ASSERT( sizeof(struct get_desktop_workarea_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_reply, screen_x) == 4 );
C_ASSERT( FIELD_OFFSET(struct get_desktop_workarea_reply, screen_y) == 4 );
C_ASSERT( sizeof(struct get_desktop_workarea_reply) == 8 );



More information about the wine-devel mailing list