C ++ / CLI前置声明 [英] C++/CLI forward declarations

查看:307
本文介绍了C ++ / CLI前置声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个头看起来像这样:

 命名空间虚拟
    {
        引用类ISYSession {};

        命名空间AFW
        {
            ///<总结>文汇冯AFW-工具,Methoden< /总结>
            公共引用类AfwUtility
            {
            上市:
                静态无效CopyAFWParamsToIDictionary(AFWParams&安培; parameterIn,系统::收藏集:: IDictionary的^ parameterOut);
                静态AFWParams * CopyIDictionaryToAFWParams(系统::收藏集:: IDictionary的^字典);
                静态无效ShowExceptionLog(系统::字符串^的sessionId);
                静态无效ShowStatementLog(系统::字符串^的sessionId);
                静态虚拟:: ISYSession ^的getSession(AFWAppClass * ACL);
            };
        }
    }
 

如果我不使用的标题为我的引用类,我不能在同一个组件使用它。但与此头我的code不能编译了。

这些是前两个错误:

C:\开发... \ xy.dll:警告C4944:'ISYSession:达斯符号卡恩nicht AUSC:\开发... \ xy.dll'importiert werden:假人:: ISYSessionIST bereits IM aktuellen Bereich vorhanden。

(英文:'虚拟:: ISYSession:符号不能从xy.dll进口:假人:: ISYSession已经存在于当前范围)

错误C3699:^:Diese Referenzierung卡恩nicht献给巢穴典型值Schleupen :: CS :: SY :: ISYSessionverwendet werden

(英文:此引用不能用于类型假人:: ISYSession')

这是怎么回事应该工作?对我来说,它似乎是编译器认为,ISYSession引用类在同一个组件定义(它不是,它在不同的.NET的DLL被定义)。

解决方案

 引用类ISYSession {};
 

这不是一个前置声明,这是一类不带任何成员的实际的类定义。修正:

 引用类ISYSession;
 

I have a header looking like this:

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

If I don't use the header for my ref class I can't use it in the same assembly. But with this header my code doesn't compile anymore.

These are the first two errors:

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

(english: "'Dummy::ISYSession': The symbol can't be imported from xy.dll: Dummy::ISYSession already exists in the current scope.")

error C3699: "^": Diese Referenzierung kann nicht für den Typ "Schleupen::CS::SY::ISYSession" verwendet werden.

(english: "This reference can't be used for Type 'Dummy::ISYSession'.")

How is this supposed to work? For me it seems that the compiler thinks that the ISYSession ref class is defined in the same assembly (which it isn't, it's defined in a different .NET DLL).

解决方案

    ref class ISYSession {};

That's not a forward declaration, that's an actual class definition for a class with no members. Fix:

    ref class ISYSession;

这篇关于C ++ / CLI前置声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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