Include file behave differently using RC.EXE or BRCC32.EXE to build *.rc files

心已入冬 提交于 2019-12-09 19:12:37

问题


I wish to using dot (.) as resource entry in RC files for my Delphi project. However, Delphi's BRCC32.exe doesn't allow dot (.) in resource naming. Since Delphi 2010, we may specify "Resource Compiler to use" in

Project | Option | Resource Compiler 

to switch to RC.exe (Windows SDK Resource Compiler) that support dot in naming.

Using RC.exe as resource compiler works for dot naming I want. However, I encounter a problem using #include in the rc file.

I have a app.db.excludes.rc file is as follow:

#include "../../../../core/resource/db/excludes/system.db.excludes.rc"

HR_BRANCH_DSC     8000  "HR.BRANCH.DSC.xml"
HR_CALENDAR_DSC   8000  "HR.CALENDAR.DSC.xml"
HR_CATEGORY_DSC   8000  "HR.CATEGORY.DSC.xml"

And system.db.excludes.rc file:

#include "../../system.h"

SYSTEM_GROUPS_DSC   8000  "SYSTEM.GROUPS.DSC.xml"
SYSTEM_SCRIPT_DSC   8000  "SYSTEM.SCRIPT.DSC.xml"
SYSTEM_USER_DSC     8000  "SYSTEM.USER.DSC.xml"

Compile the Delphi project yields:

[BRCC32 Error] payroll.db.excludes.rc(3): file not found: SYSTEM.GROUPS.DSC.xml
[BRCC32 Error] payroll.db.excludes.rc(4): file not found: SYSTEM.SCRIPT.DSC.xml
[BRCC32 Error] payroll.db.excludes.rc(5): file not found: SYSTEM.USER.DSC.xml

The above problem occurs if using RC.exe. It works without any problems if I use BRCC32.exe.

This problem is due to both app.db.excludes.rc and system.db.excludes.rc isn't keep in same folder.

If I change system.db.excludes.rc to

#include "../../system.h"

SYSTEM_GROUPS_DSC   8000  "../../../../core/resource/db/excludes/SYSTEM.GROUPS.DSC.xml"
SYSTEM_SCRIPT_DSC   8000  "../../../../core/resource/db/excludes/SYSTEM.SCRIPT.DSC.xml"
SYSTEM_USER_DSC     8000  "../../../../core/resource/db/excludes/SYSTEM.USER.DSC.xml"

The RC.exe will then compile successfully.

Does anyone has any ideas how to make RC.exe works as BRCC32.EXE when interpret the include files as above?


回答1:


You could try the /I option of RC to specify the directory in which your XML files live. You'd have to run RC as a pre-build action in order to get that much control over its execution environment.




回答2:


Instead of using #include to embed a rc file:

#include "../../../../core/resource/db/excludes/system.db.excludes.rc"

I remove the usage of #include and add "system.db.excludes.rc" into my Delphi project (.dproj).

The patched "app.db.excludes.rc" is:

HR_BRANCH_DSC     8000  "HR.BRANCH.DSC.xml"
HR_CALENDAR_DSC   8000  "HR.CALENDAR.DSC.xml"
HR_CATEGORY_DSC   8000  "HR.CATEGORY.DSC.xml"

And my Delphi package file (.dpk) is as follow:

package resource.db;

{$R *.res}
{$R 'payroll.db.excludes.res'}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
....

A resource entry should added to the .dpk file manually:

{$R 'payroll.db.excludes.res'}

This approach works for both BRCC32.exe and CGRC.exe / RC.exe.



来源:https://stackoverflow.com/questions/4538131/include-file-behave-differently-using-rc-exe-or-brcc32-exe-to-build-rc-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!