0

Some of resources from .RC file are not available in resulting .exe with the ID's given in .RC file. I have and RC file with resourcestrings with id's 10000, 10100 etc. At some reason, when I load resource with id 10000 (LoadStr(10000)) it loads another string ('Invalid field type.' - which is declared in midas.rc from VCL and has the same id).

I assumed that resources with the same id should lead to "[Error] WARNING. Duplicate resource(s)" during the build. But there is no linker-related warnings.

p.s. I'm using Delphi 2010.

Update:

  • Workaround on that issue is to change id from 10000 to something else. 10050, e.g.

Question:

  • Why there's no warnings on duplicate resources?
  • What could be done to prevent that problem in future?

myproject.inc

const
  offLanguages   = 10000;
  offCurrencies  = 10100;

myproject.RC file

LANGUAGE LANG_LATVIAN, SUBLANG_NEUTRAL

#include "myproject.inc"

STRINGTABLE
{
 offLanguages+0, "LV"
}

.. etc...

Rc file is compiled to myproject.res file. And the resulting .res files has correct string "LV" with ID 10000 (I checked that with resource editor).

In delphi coude resources are loaded in unit's initialization part, using LoadStr function.

likeThat.pas:

unit likeThat;

interface

{$I *.inc}
{$R *.res}

// skipped

initialization
  Assert(LoadStr( offLanguages )= 'LV'); // <== fails here
Aleksey Timohin
  • 591
  • 1
  • 9
  • 15
  • Sure there's no "define sth 10000" in "myprojectlv.rc"? – Sertac Akyuz Sep 21 '14 at 01:30
  • Absolutely sure. Also, there absolutely no LINKER warnings when I compile exe in IDE. (I'll edit question to remove that disambiguation) – Aleksey Timohin Sep 21 '14 at 01:38
  • It's a big project, which uses many different libraries (JCL, JVCL, Developer Express, Fast Reports etc), so theoretically resource with the same ID cou could present in some other .res files. But I assume that it will lead to "[Error] WARNING. Duplicate resource(s)" during build compile. But as I mentioned earlier, I got no warnings. – Aleksey Timohin Sep 21 '14 at 01:45
  • 1
    I expect those libraries to use resourcestrings. – Sertac Akyuz Sep 21 '14 at 01:50
  • I actually find the string that is loaded instead of mine is declared in VCL in midas.rc file and uses the same ID. Now the questions are "why there's no warnings on duplicate resources?" and "what could be done to prevent that problem in future?" – Aleksey Timohin Sep 21 '14 at 01:55
  • 2
    Use resourcestrings. – Sertac Akyuz Sep 21 '14 at 01:58
  • That's not a solution in my case, as this code uses formula with 3 different parameters to calculate resource ID and load the correct one. Converting to resourcestrings will make it a mess. – Aleksey Timohin Sep 21 '14 at 02:04
  • Don't link with Midas (use the dll)? I guess my point is, if you don't get a RLINK, there's not much you can do. – Sertac Akyuz Sep 21 '14 at 02:07
  • Thank you for help. I already found workaround for that issue (change id for my resource), but just wanted to insure myself from getting into that bug again in future. – Aleksey Timohin Sep 21 '14 at 02:22

0 Answers0