C ++ / CLI前向声明

时间:2012-02-02 09:59:23

标签: c++ .net c++-cli forward-declaration

我的标题看起来像这样:

    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);
            };
        }
    }

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

这是前两个错误:

c:\ develop ... \ xy.dll:警告C4944:'ISYSession':Das Symbol kann nicht aus'c:\ develop ... \ xy.dll'importiert werden:'Dummy :: ISYSession'ist bereits im aktuellen Bereich vorhanden。

(英文:“'Dummy :: ISYSession':无法从xy.dll导入符号:Dummy :: ISYSession已存在于当前范围内。”)

错误C3699:“^”:Diese Referenzierung kannnichtfürdenTyp“Schleupen :: CS :: SY :: ISYSession”verwendet werden。

(英文:“此引用不能用于Type'Dummy :: ISYSession'。”)

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

1 个答案:

答案 0 :(得分:9)

    ref class ISYSession {};

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

    ref class ISYSession;
相关问题