[Tip: using namespace in C++/CLI]

In a managed C++ project, we can use the “using namespace” expression to include managed types. Just like using “#include” incorrectly will cause some compile error, declaring “using namespace”  globally will cause some problems too. We encountered “ambiguous symbol” error when integrating ASM 4100. To resolve the issue, we can make the “using namespace” impact locally.

 

For example. The following code may have “ambiguous symbols” error:

 

// FIExternalDatabaseInfo.h

using namespace System;

 

namespace Autodesk

{

namespace Catalyst

{

namespace Freeway

{

namespace Components

{

namespace FIExternalDatabaseInfo

{

 

  public ref class ExternalDatabaseInfo {

}

}

 

We can resolve it by using System namespace inside Autodesk::Catalyst::Freeway::Components::FIExternalDatabaseInfo only:

 

namespace Autodesk

{

namespace Catalyst

{

namespace Freeway

{

namespace Components

{

namespace FIExternalDatabaseInfo

{

  using namespace System;

 

  public ref class ExternalDatabaseInfo {

};

}

 

原文链接: https://www.cnblogs.com/taoxu0903/archive/2010/10/27/1862475.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    [Tip: using namespace in C++/CLI]

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/16644

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月7日 下午5:00
下一篇 2023年2月7日 下午5:01

相关推荐