简体   繁体   English

使用CUDA和Maya API时命名空间发生冲突

[英]Namespace clash when using CUDA and Maya API

I'm trying to compile a Maya 2014 plugin using CUDA v5.5 (in VS2010), and if I try to include both CUDA (specifically vector_types.h), I get errors that stem from the fact that both Maya and CUDA define the same types: 我正在尝试使用CUDA v5.5(在VS2010中)编译Maya 2014插件,如果我尝试包含两个CUDA(特别是vector_types.h),我会得到错误,这些错误源于Maya和CUDA都定义了相同类型:

C:\program files\nvidia gpu computing toolkit\cuda\v5.5\include\vector_types.h(148): error C2371: 'short2' : redefinition; different basic types
C:\Program Files\Autodesk\Maya2014\include\maya/MTypes.h(269) : see declaration of 'short2'

I'm not exactly sure how to fix this. 我不确定如何解决这个问题。 Any thoughts? 有什么想法吗?

Thanks! 谢谢!

Edit: 编辑:

I looked into the idea of wrapping the include in a namespace and found that it does not work well. 我研究了将include包装在命名空间中的想法,并发现它不能正常工作。 The problem is that the namespace is included in the mangled name, so you get undefined symbols when linking. 问题是命名空间包含在受损名称中,因此在链接时会得到未定义的符号。

The only workable way I found (except for modifying one of the libraries) is to create a separate source file, include the conflicting file only there and create wrappers for the conflicting types and functions. 我找到的唯一可行方法(除了修改其中一个库)是创建一个单独的源文件,仅在那里包含冲突文件,并为冲突类型和函数创建包装器。


Wrapping one #include in a namespace might work... 在命名空间中包装一个#include可能有效......

namespace maya
{
   #include "maya.h"
};

Then, reference the symbols from maya.h via the namespace: 然后,通过命名空间引用maya.h的符号:

maya::some_maya_symbol . maya::some_maya_symbol

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM