[fpc-pascal] {$R file} support on non-Windows targets

Giulio Bernardi ugilio at gmail.com
Thu Jul 10 11:13:48 CEST 2008


Graeme Geldenhuys ha scritto:
> On Thu, Jul 10, 2008 at 9:13 AM, Giulio Bernardi <ugilio at gmail.com> wrote:
>> vendor provide their own (brcc32 from borland, wrc from watcom, gorc), but
>> they are not "cross platform", even if wrc is able to compile  win32, win16
>> and os2 resource files for those systems.
> 
> You stole my example! :-) I was just about to mention Watcom's
> resource compiler. If it works for Win32, Win16 and OS/2, how can it
> not be cross-platform?  Or do you mean not cross-platform, because a
> .res file compiled under OS/2 cannot be used as-is under Win32?

Exactly. E.g. OS/2's .res format is like the win16 one but without 
support for string IDs (that is, you can't have a os/2 resource named 
'MYFORM'). Moreover they have little syntax differences here and there.
For what regards wrc, it's simple: you tell wrc you want to compile a 
win32 rc file, and it will output a win32 .res file. If you tell it to 
use win16 format, .rc file must use that syntax and it will be compiled 
as a win16 resource.
So you can't use wrc to compile a win32 rc file to a os2 res file: it's 
like to have three separate resource compilers in one.

>  If
> the latter, would that really be an issue for FPC with a slogan like
> "write once, compile everywhere". As long as the application is
> compiled on the platform it needs to run on, the resource will be
> correct.  This excludes cross-compiling, no idea how that works.
> 
The idea is that we support win32 resources everywhere, since the {$R} 
stuff comes from delphi, where it's used for win32 resources.
At the moment, winlike resources aren't supported on os/2 or classic mac 
os because one might want to use their platform-specific resources. One 
idea I have is to add something like {$resmode native/win32} (example 
case: lazarus starts using resources, someone decides to port lazarus to 
os/2, we have a problem. With the switch a program could contain both 
win32 resources used by lazarus and os2 resources like the program icon 
and so on).

Giulio




More information about the fpc-pascal mailing list