关于可怕的MC ++的问题 [英] Question about the dreaded MC++

查看:83
本文介绍了关于可怕的MC ++的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个包含非托管和托管部分的项目,那么托管C ++是否可以在

右位正确处理垃圾收集器?

解决方案

是的。


您有更具体的信息吗?


Ronald Laeremans
Visual C ++团队


" songie D" <所以**** @ D.com>在消息中写道

新闻:%2 *************** @ tk2msftngp13.phx.gbl ...

可以管理C ++如果我有一个包含非托管和托管部分的项目,那么可以信任正确处理垃圾收集器吗



>是的。


好​​的,好的!我听说过你经常不得不担心gc'正在做什么,但我还没有遇到任何问题。 />


你有更具体的东西吗?


嗯...是的,现在你来提一下。

我想用命名空间添加

System :: Runtime :: InteropServices;


到我的项目,但它给出了错误


C:\Program Files \ Microsoft Visual Studio .NET

2003 \Vc7 \PlatformSDK \ Include\WinBase.h(3139):错误C2872:''FILETIME'':

模糊符号


可能是''C:\Program Files \ Microsoft Visual Studio .NET

2003 \Vc7 \PlatformSDK \ Include; \\ WinDef .h(354):_ FILETIME FILETIME''


或''stdafx.cpp(0):System :: Runtime :: InteropServices :: FILETIME''


很多次。我可以通过在命名空间的所有调用之前放置显式命名空间名称

来绕过它,但这有点麻烦。任何想法

如何解决它?


另外,在一个单独的.cpp文件中有一个非托管函数,以及
$ b IDE中给你的$ b托管代码(即Form1.h),如何使用externC链接到

非托管函数?或其他?

我是否必须在声明中放置#pragma unmanaged?

Ronald Laeremans
Visual C ++团队

" songie D" <所以**** @ D.com>在消息中写道
新闻:%2 *************** @ tk2msftngp13.phx.gbl ...

托管C ++可以信任处理如果我的项目中包含非托管和托管部分,那么垃圾收集器是否正确?




Songie,

嗯...是的,现在你来提一下。
我正在尝试添加
使用命名空间System :: Runtime :: InteropServices;

我的项目,但它给出了错误

C:\Program Files \ Microsoft Visual Studio .NET
2003 \Vc7 \PlatformSDK \ Include; \\ WinBase.h(3139):错误C2872:''FILETIME'':
含糊不清的符号

可能是'' C:\Program Files \ Microsoft Visual Studio .NET
2003 \Vc7 \PlatformSDK \ Include \ WinDef.h(354):_ FILETIME FILETIME''

或' 'stdafx.cpp(0):System :: Runtime :: InteropServi ces :: FILETIME''

很多次。我可以通过在命名空间的所有调用之前放置显式命名空间名称来解决它,但这有点麻烦。任何
的想法我怎么解决它?


使用typedef是一种简单的方法:


typedef System :: Runtime :: InteropServices :: FILETIME NETFT;


NETFT tm ....;


另外,在一个单独的.cpp文件中有一个非托管函数,以及
托管代码在IDE给你的东西(即Form1.h)中,如何使用externC链接到非托管函数?或其他?


头文件可以正常工作。

我是否必须在声明中放置#pragma unmanaged?



不。你可能想把它放在函数的定义上,如果你确实要确保编译器为

生成x86代码(而不是CIL),尽管(虽然)你可以简单地编译包含的.cpp文件

没有/ clr)。


-

Tomas Restrepo
to****@mvps.org


Can managed C++ be trusted to handle the garbage collector correctly in the
right bit if I have a project with unmanaged and managed parts in it?

解决方案

Yes.

Is there something more specific you are after?

Ronald Laeremans
Visual C++ team

"songie D" <so****@D.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Can managed C++ be trusted to handle the garbage collector correctly in
the
right bit if I have a project with unmanaged and managed parts in it?



> Yes.

OK, good! I''d heard rumours that you "constantly have to worry about what
the gc''s doing", but I''ve not ran into any problems with that, as yet.


Is there something more specific you are after?
ermm...yes, now you come to mention it.
I''m trying to add
using namespace System::Runtime::InteropServices;

to my project, but it gives the error

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinBase.h(3139) : error C2872: ''FILETIME'' :
ambiguous symbol

could be ''C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinDef.h(354) : _FILETIME FILETIME''

or ''stdafx.cpp(0) : System::Runtime::InteropServices::FILETIME''

many times. I can get round it by putting the explicit namespace name
preceeding all calls to the namespace, but that''s a bit cumbersome. Any idea
how I can resolve it?

Also, for having an unmanaged function in one separate .cpp file, and the
managed code in what the IDE gives you (i.e. Form1.h), how would I link to
the unmanaged function, using extern "C"? or other?
Would I have to put #pragma unmanaged round the declaration?

Ronald Laeremans
Visual C++ team

"songie D" <so****@D.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Can managed C++ be trusted to handle the garbage collector correctly in
the
right bit if I have a project with unmanaged and managed parts in it?




Songie,

ermm...yes, now you come to mention it.
I''m trying to add
using namespace System::Runtime::InteropServices;

to my project, but it gives the error

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinBase.h(3139) : error C2872: ''FILETIME'' :
ambiguous symbol

could be ''C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinDef.h(354) : _FILETIME FILETIME''

or ''stdafx.cpp(0) : System::Runtime::InteropServices::FILETIME''

many times. I can get round it by putting the explicit namespace name
preceeding all calls to the namespace, but that''s a bit cumbersome. Any idea how I can resolve it?
Using a typedef is a simple way around it:

typedef System::Runtime::InteropServices::FILETIME NETFT;

NETFT tm....;


Also, for having an unmanaged function in one separate .cpp file, and the
managed code in what the IDE gives you (i.e. Form1.h), how would I link to
the unmanaged function, using extern "C"? or other?
Header files would work just fine.
Would I have to put #pragma unmanaged round the declaration?



nope. You might want to put it on the definition of the function if you
really want to ensure the compiler generates x86 code (instead of CIL) for
it, though (although you could simply compile the containing .cpp file
without /clr, as well).

--
Tomas Restrepo
to****@mvps.org


这篇关于关于可怕的MC ++的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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