1

我已经从 Rad studio 的官方网站下载了 TVersionInfo VCL,并在我的 IDE 中成功安装了它,因为它们出现在我的工具箱面板中。将其粘贴到我的项目中并第一次尝试构建它。我确信它会构建好,因为我已经运行了它附带的测试项目。没问题。但是在我的项目中,在编译过程中出现了错误。由于使用 Fib plus 包进行 interbase db 访问连接,这一切都发生在我身上。以下是消息中出现的错误:

Checking project dependencies...
Compiling Invoice.cbproj (Debug configuration)
[BCC32 Error] VersionInfoUI.h(24): E2015 Ambiguity between 'TVersionInfo' and 'Ib_services::TVersionInfo'
  Full parser context
    main.cpp(10): #include about.h
    about.h(11): #include D:\CB2010_VCL\VersionInfo\VersionInfoUI.h
    VersionInfoUI.h(11): class TCustomVersionInfoLabel
[BCC32 Error] VersionInfoUI.h(25): E2015 Ambiguity between 'TVersionInfo' and 'Ib_services::TVersionInfo'
  Full parser context
    main.cpp(10): #include about.h
    about.h(11): #include D:\CB2010_VCL\VersionInfo\VersionInfoUI.h
    VersionInfoUI.h(11): class TCustomVersionInfoLabel
[BCC32 Error] VersionInfoUI.h(39): E2015 Ambiguity between 'TVersionInfo' and 'Ib_services::TVersionInfo'
  Full parser context
    main.cpp(10): #include about.h
    about.h(11): #include D:\CB2010_VCL\VersionInfo\VersionInfoUI.h
    VersionInfoUI.h(11): class TCustomVersionInfoLabel
[BCC32 Error] about.h(16): E2015 Ambiguity between 'TVersionInfo' and 'Ib_services::TVersionInfo'
  Full parser context
    main.cpp(10): #include about.h
    about.h(13): class TfAbout
Failed
Elapsed time: 00:00:04.0  

我认为 FIB IB 服务类也具有相同的类名,因此两个类名之间存在冲突。如何解决这个问题?如何使两个类像使用命名空间或其他东西一样一起工作?

4

1 回答 1

1

Delphi 为 VCL 组件生成的 .hpp 文件被包装在命名空间中。问题是他们还倾向于使用using namespace ...它们底部的语句将所有内容转储到全局命名空间中,这完全违背了使用命名空间的目的。如果您查看此类 .hpp 文件的底部,您将看到#ifdef向您显示可以在项目中定义哪些值以禁用此行为的语句。另一种方法是在设计时根本不使用TVersionInfo。在您的运行时代码中动态创建它,而不是通过new运算符,然后您可以指定它来自哪个命名空间。

于 2012-08-27T23:58:25.383 回答