Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2023-05

Resources without RC files

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

Hello,

I see that the LCL includes LFM files as resources directly without a *.RC file:

{$R *.lfm}

---

But if I do this with my custom file. E.g.:

{$R *.sql}

I get an "error when compiling resources":

Compile Project, Mode: Debug, Target: Test.exe: Exit code 1, Errors: 1, Warnings: 1
Warning: windres: can't open file `REPLACE': No such file or directory uTest.pas(96,0) Error: Error while compiling resources -> Compile with -vd for more details. Check for duplicates.

---

How is it possible that the LFM files are included directly but *.SQL files are parsed as RC files?

---

I checked the Wiki and Docs, but didn't find any information about it:

https://wiki.freepascal.org/Lazarus_Resources
https://www.freepascal.org/docs-html/prog/progsu67.html#x74-730001.2.67

Thanks
Ondrej

Reply by email

Michael Van Canneyt
to Ondrej Pokorny
Ondrej Pokorny wrote 25 lines
Hello, I see that the LCL includes LFM files as resources directly without a *.RC file: {$R *.lfm} --- But if I do this with my custom file. E.g.: {$R *.sql} I get an "error when compiling resources": Compile Project, Mode: Debug, Target: Test.exe: Exit code 1, Errors: 1, Warnings: 1 Warning: windres: can't open file `REPLACE': No such file or directory uTest.pas(96,0) Error: Error while compiling resources -> Compile with -vd for more details. Check for duplicates. --- How is it possible that the LFM files are included directly but *.SQL files are parsed as RC files?

Because the file extension is recognized ? LFM is included as RC_DATA, and probably everything that is not .lfm is assumed to be a RC format.

I believe fpcres also has this check.

Michael.

Reply by email

Ondrej Pokorny
to Michael Van Canneyt
Michael Van Canneyt wrote 8 lines
On Thu, 4 May 2023, Ondrej Pokorny via lazarus wrote: > How is it possible that the LFM files are included directly but *.SQL > files are parsed as RC files? Because the file extension is recognized ? LFM is included as RC_DATA, and probably everything that is not .lfm is assumed to be a RC format. I believe fpcres also has this check.

Thanks for the tip. I found it - it is directly in the compiler.

In comprsrc.pas TWinLikeResourceFile.IsCompiled there is a logic that defines what the compiler does with the included resource file based on the extension or file header.

I don't like the fact that there are hard-coded constants for what seems to be (for a stranger) arbitrary file extensions and that it is not documented anywhere.

I will raise the question in the FPC mailing list.

Ondrej

Reply by email

Michael Van Canneyt
to Ondrej Pokorny
Ondrej Pokorny wrote 19 lines
On 04.05.2023 08:38, Michael Van Canneyt wrote: > On Thu, 4 May 2023, Ondrej Pokorny via lazarus wrote: >> How is it possible that the LFM files are included directly but *.SQL >> files are parsed as RC files? > > Because the file extension is recognized ? LFM is included as RC_DATA, and > probably everything that is not .lfm is assumed to be a RC format. > > I believe fpcres also has this check. Thanks for the tip. I found it - it is directly in the compiler. In comprsrc.pas TWinLikeResourceFile.IsCompiled there is a logic that defines what the compiler does with the included resource file based on the extension or file header. I don't like the fact that there are hard-coded constants for what seems to be (for a stranger) arbitrary file extensions and that it is not documented anywhere.

Well, developers that are using lazarus and form files know what happens.

This is undoubtedly the majority of FPC users, so I don't think this is an issue.

But it should definitely be documented.

Michael.

Reply by email

Ondrej Pokorny
to Michael Van Canneyt
Michael Van Canneyt wrote 27 lines
On Thu, 4 May 2023, Ondrej Pokorny wrote: > On 04.05.2023 08:38, Michael Van Canneyt wrote: >> On Thu, 4 May 2023, Ondrej Pokorny via lazarus wrote: >>> How is it possible that the LFM files are included directly but >>> *.SQL files are parsed as RC files? >> >> Because the file extension is recognized ? LFM is included as >> RC_DATA, and probably everything that is not .lfm is assumed to be a >> RC format. >> >> I believe fpcres also has this check. > > Thanks for the tip. I found it - it is directly in the compiler. > > In comprsrc.pas TWinLikeResourceFile.IsCompiled there is a logic that > defines what the compiler does with the included resource file based > on the extension or file header. > > I don't like the fact that there are hard-coded constants for what > seems to be (for a stranger) arbitrary file extensions and that it is > not documented anywhere. Well, developers that are using lazarus and form files know what happens. This is undoubtedly the majority of FPC users, so I don't think this is an issue.

It is still confusing - in pas2js any file can be added as a resource with:

{$R abc.xyz}

In FPC only LFM, so hence the question why and how :)

Ondrej

Reply by email