This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Windres questions


Danny Backx <danny.backx@scarlet.be> writes:

> 1. From the documentation I see on MSDN, the snippet below doesn't
>   appear to be valid. The LTEXT line ends with a comma, which indicates
>   that a style should follow. But it doesn't.
> 
>   Look at http://msdn2.microsoft.com/en-us/library/aa381021.aspx for
>   a description, the syntax is :
>         LTEXT text, id, x, y, width, height [[, style
>                  [[, extended-style]]]]
> 
>   Effectively, the arm-wince-cegcc-windres fails to compile this line,
>   but it accepts it when the comma at the end of the line is removed.
> 
>   Question : this is based on one of the examples in the Boling book,
>   which is from Microsoft Press. Is the example wrong ?
> 
> SMSTalk_PPC DIALOG discardable  25, 5, 120,  98
> STYLE  WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU | DS_MODALFRAME
> CAPTION "SMS Talk"
> FONT 8, "System"
> BEGIN
>     LTEXT   "Received Messages",   -1,   4,   4, 128,  10,
>     LISTBOX               IDD_MSGLIST,   4,  14, 128,  48, WS_TABSTOP
> 
> END

The syntax accepted by the Microsoft resource compiler is not
precisely the same as the syntax described by the Microsoft
documentation.  Where they differ in minor ways, it seems preferable
to follow the program rather than the documentation, especially if it
means that we accept programs that we would otherwise reject.

In other words: try running the Microsoft resource compiler on that
bit of code and see what happens.


> 2. Windres calls the C preprocessor to deal with macros. This is a
>    sensible thing to do because they appear to follow the C syntax.
> 
>    However, this makes it hard to produce sensible error messages.
>    Consider an input such as this :
> ID_MENU_SP RCDATA MOVEABLE PURE 
> BEGIN
>     ID_MENU_SP, 2,
>     I_IMAGENONE, IDOK,  TBSTATE_ENABLED, TBSTYLE_BUTTON | 
>                                   TBSTYLE_AUTOSIZE, IDS_EXIT, 0, NOMENU,
>     I_IMAGENONE, IDPOP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | 
>                                   TBSTYLE_AUTOSIZE, IDS_MENU, 0, 0,
> END
> 
>    The C preprocessor turns it into this :
> 100 RCDATA MOVEABLE PURE
> BEGIN
>     100, 2,
>     (-2), 1, 4, 0 |
>                                   16, 401, 0, NOMENU,
>     (-2), 208, 4, 8 |
>                                   16, 402, 0, 0,
> END
> 
>    Error messages will describe stuff in the latter format which is
>    unknown and therefore incomprehensible to the programmer. Not good.
> 
>    However, the syntax allowed appears to be a manageable subset of
>    the C syntax. Would it be a silly idea to implement that limited
>    subset in windres so it becomes independent of the C preprocessor
>    and can write better error messages ?

Resource files sometimes include Windows header files.  The Windows
header files use #ifndef RC_INVOKED to hide C/C++ code which the
resource compiler does not understand.  This means that windres can
see arbitrary preprocessor code.  I do not think it would be
appropriate to implement the preprocessor in windres.  I suppose you
could try linking it with gcc's libcpp, though that would make it
awkward to build.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]