TColor Initialise with int 适用于 {} 但不适用于 ()

问题描述

我在 IDE 中使用 Embarcader C++Builder 10.4.2 和 Clang32 编译器来构建 VCL Windows 32 位应用程序。

当我使用旧的“经典”编译器时,我曾经为我自己的 () 常量使用 TColor 初始值设定项。但是 Clang32 编译器不接受这一点。 Clang32 确实接受相同的初始化值,但使用 C++ 17(以及我认为更早的版本){} 初始化器。

感谢 Remy 的建议:我应该在我的原始帖子中包含错误消息。 Clang32编译器报的错误信息是:

[C++ 错误] Unit1.cpp(15,13): 无法用类型为 'int' 的右值初始化类型为 'const System::Uitypes::TColor' 的变量

我不明白为什么 Clang32 不喜欢 () 初始值设定项语法。谁能解释一下?

附上代码示例:

#include <vcl.h>

const TColor MeterBarBezelRimColour{0x00DDDDDD};   // works with Clang32 - (too "modern" for Classic compiler)
    
const TColor AnotherBezelRimColour(0x00CCCCCC);    // give an error with Clang32 (but does work for Classic compiler).

// WHY is this not accepted by Clang?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)