Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate resource warning from same file

Tags:

delphi

I am getting this rather confusing compiler warning:

[DCC Warning] W1056 Warning: Duplicate resource: Type 14 (ICON GROUP), ID MAINICON; File C:\dev\dispense\trunk\dev\source\mountaintop\dispense\MtnDispense.res resource kept; file C:\dev\dispense\trunk\dev\source\mountaintop\dispense\MtnDispense.res resource discarded.

In case the formatting isn't clear; the two paths it mentions are identical.

The application doesn't have any entries under Project->Resources

The application has a custom icon, defined under Project->Options->Application->Icon.

Does this warning mean anything? And how can I remove it?

like image 942
awmross Avatar asked Nov 13 '11 23:11

awmross


3 Answers

It means the resource file is being imported more than once. You should only have one

{$R *.res}

in your dpr file. To fix the error, remove the extra ones.

like image 74
crefird Avatar answered Nov 12 '22 20:11

crefird


I reproduced your problem:

program ProjectName;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}
{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Remove the second compiler directive. Or there is a {$R ProjectName.res} somewhere in another source file.

like image 42
NGLN Avatar answered Nov 12 '22 20:11

NGLN


In my case the problem was like this:

Program xyz;
 
uses
  FastMM4,
  Windows,
  SysUtils,
  Forms,
  cIO,
  FormManager in 'FormManager.pas' {FrmManager} {$R *.RES}; <----- HERE

{$R *.RES}

The IDE corrupted the DPR file and accidentally added an extra $R directive in the 'uses'. Actually, this is not a "happen once" case. I see this from time to time.
This explains your:

No idea how that got there (accidental paste??).

like image 2
Server Overflow Avatar answered Nov 12 '22 18:11

Server Overflow