OnT*_*Fly 7 delphi compiler-construction conditional-compilation conditional-expressions delphi-xe
请考虑以下代码段:
requires
designide,
rtl,
vcl,
{$IF RTLVersion < 19.0} // E2026 Constant expression expected
//{$IF CompilerVersion = 22.0} // same as above
vcljpg;
{$ELSE}
vclimg;
{$IFEND}
Run Code Online (Sandbox Code Playgroud)
它似乎在语法上是正确的.但是,编译器会对其进行扼流并报告Constant expression expected.这里到底发生了什么?
技术:目前仅在XE(15.0.3953.35171)上测试过.
当然,也欢迎变通方法的建议.
RRU*_*RUZ 12
我在过去发现了同样的问题,即使使用delphi 2007.作为解决方法,我使用带有条件定义的inc文件,然后使用{$IFDEF}而不是{$IF}
这样的事情
{$I MyDefines.INC}
requires
designide,
rtl,
vcl,
{$IFDEF DELPHI_XE_UP} //the DELPHI_XE_UP is defineed inside of MyDefines.INC
uNewlib;
{$ELSE}
uOldLib;
{$ENDIF}
Run Code Online (Sandbox Code Playgroud)
package模块program与library模块不同.它们不包含可执行代码,也不能包含use单位.因此,RTLVersion从包文件中看不到符号.您唯一的选择是使用$IFDEF.
| 归档时间: |
|
| 查看次数: |
870 次 |
| 最近记录: |