C++/CLI向前声明

C++/CLI向前声明

问题描述:

我有一个头看起来像这样:C++/CLI向前声明

namespace Dummy 
    { 
     ref class ISYSession {}; 

     namespace Afw 
     { 
      /// <summary>Sammlung von AFW-Utility-Methoden</summary> 
      public ref class AfwUtility 
      { 
      public: 
       static void CopyAFWParamsToIDictionary(AFWParams &parameterIn, System::Collections::IDictionary^ parameterOut); 
       static AFWParams* CopyIDictionaryToAFWParams(System::Collections::IDictionary^ dictionary); 
       static void ShowExceptionLog(System::String^ sessionId); 
       static void ShowStatementLog(System::String^ sessionId); 
       static Dummy::ISYSession^ GetSession(AFWAppClass *acl); 
      }; 
     } 
    } 

如果我不使用的标题为我的引用类,我不能在同一程序中使用它。但有了这个头文件,我的代码不再编译。

这是第一次两个错误:

C:\开发... \ xy.dll:警告C4944: 'ISYSession':达斯符号卡恩nicht AUS“C:\开发... \ XY。 dll'importiert werden:'Dummy :: ISYSession'ist bereits im aktuellen Bereich vorhanden。

(英文: “ '假人:: ISYSession':符号不能从xy.dll进口:假人:: ISYSession已存在在目前的范围。”)

错误C3699: “^” :Diese Referenzierung kann nichtfürden Typ“Schleupen :: CS :: SY :: ISYSession”verwendet werden。

(英语:“此引用不能被用于类型‘假人:: ISYSession’。”)

这是怎么应该工作?对我来说,似乎编译器认为ISYSession ref类是在同一个程序集中定义的(它不是,它是在不同的.NET DLL中定义的)。

ref class ISYSession {}; 

这不是一个前向声明,这是一个没有成员的类的实际类定义。修复:

ref class ISYSession; 
+0

是的,这确实是问题.... – Antineutrino 2012-02-29 15:25:31