条件表达式在包中是否断开? [英] Are conditional expressions broken within packages?

本文介绍了条件表达式在包中是否断开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下代码段:

requires
  designide,
  rtl,
  vcl,
  {$IF RTLVersion < 19.0}            // E2026 Constant expression expected
  //{$IF CompilerVersion = 22.0}     // same as above
  vcljpg;
  {$ELSE}
  vclimg;
  {$IFEND}

似乎绝对句法上正确。但是,编译器会阻塞它,并报告期望的常量表达式

It seems to be absolutely syntactically correct. However, the compiler chokes on it and reports Constant expression expected. What really happens here?

技术:目前仅在XE(15.0.3953.35171)上测试。

Technical: currently tested on XE (15.0.3953.35171) only.

,解决方法的建议也是欢迎的。

Of course, workaround suggestions are welcome too.

推荐答案

我发现同样的问题,甚至与delphi 2007.作为解决方法,一个带有条件定义的inc文件,然后使用 {$ IFDEF} 而不是 {$ IF}

I found the same issue in the past even with delphi 2007. As workaround, I use a inc file with the conditional defines and then use {$IFDEF} instead of {$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}

这篇关于条件表达式在包中是否断开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆