开发者

Compile rc files encounter "expected exponent value" error

I have a rc entry:

{CC6C210B-2EAC-4F6C-89E7-0D2FEFFCE278}  8000  "MyFile.txt"

When I compile the rc file with cgrc.exe or brcc32.exe, I encounter this error:

[BRCC32 Error] system.core.rc(1): expected exponent value, not 'a'

This开发者_运维问答 is due to the resource name "CC6C210B-2EAC" was interpreted as exponent value (-2EA). The A character after -2E is not valid exponent value.

If I change the rc entry to something like

{CC6C210B-2E2C-4F6C-89E7-0D2FEFFCE278}  8000  "MyFile.txt"

The resource compile without any error.

Unfortunately, I can't simply change the resource name as it has been widely used. Is there any ways to make rc do not interpret resource name as exponent value?


I'm not so sure it was a good idea to use a GUID as resource name. If you really want to do that, you might want to "encode" it as a "normal" identifier, e.g.

_CC6C210B_2EAC_4F6C_89E7_0D2FEFFCE278  8000  "MyFile.txt"

You just write a set of simple routines to "encode" and "decode" such a value between a normal GUID string and the "encoded" form.

function DecodeToGUID(const renamedGUID: string): string;
begin
  Result := '{' + Copy(ReplaceString(renamedGUID, '_', '-', [rfReplaceAll]), 2, MaxInt)) + '}';
end;

I'll leave the implementation of the other routine to your imagination. ;-)


Update

If you put the ID in quotes, it should compile, with rc.exe. Without the quotes, the resource compiler will treat it as a preprocessor directive and get terribly confused:

"{CC6C210B-2EAC-4F6C-89E7-0D2FEFFCE278}"  8000  "MyFile.txt"

I tested this with Microsoft's rc.exe. Embarcadero's brcc32.exe will still give an error:

Error resrc.rc 1 1: Expecting resource name or resource type name

So if you want to use that, or the built in resource compiler of the IDE, you'll have to use something like the renamed GUIDs as described above.


I recommend that you use the Microsoft resource compiler rc. According to the documentation for rc, the first token of a resource definition should be a name or a 16 bit integer. Why brcc32 wants to interpret this as a real value is quite beyond me.

If this doesn't work try enclosing the GUID in quotes, " rather than '.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜