我如何决定是否为新的 C++ 项目使用 ATL、MFC、Win32 或 CLR? [英] How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?

查看:12
本文介绍了我如何决定是否为新的 C++ 项目使用 ATL、MFC、Win32 或 CLR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始我的第一个 C++ 项目.我正在使用 Visual Studio 2008.它是一个单一形式的 Windows 应用程序,它访问几个数据库并启动一个 WebSphere MQ 事务.我基本上了解 ATL、MFC、Win32(我实际上对那个有点模糊)和 CLR 之间的区别,但我不知道应该如何选择.

I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically understand the differences among ATL, MFC, Win32 (I'm a little hazy on that one actually) and CLR, but I'm at a loss as to how I should choose.

其中一个或多个只是为了向后兼容吗?

Is one or more of these just there for backward-compatibility?

CLR 是个坏主意吗?

任何建议表示赞赏.

我为这个项目选择了 C++,因为我没有在帖子中提到,这并不完全是技术性的.那么,假设 C++ 是唯一/最好的选择,我应该选择哪个?

I've chosen C++ for this project for reasons I didn't go into in the post, which are not entirely technical. So, assuming C++ is the only/best option, which should I choose?

推荐答案

这取决于你的需求.

使用 CLR 将为您提供最具表现力的库集(整个 .NET 框架),但代价是将您的可执行文件限制为要求在运行时安装 .NET 框架,以及将您限制在Windows 平台(但是,所有列出的 4 种技术都只是 Windows,因此平台限制可能是最不麻烦的).

Using the CLR will provide you with the most expressive set of libraries (the entire .NET framework), at the cost of restricting your executable to requiring the .NET framework to be installed at runtime, as well as limiting you to the Windows platform (however, all 4 listed technologies are windows only, so the platform limitation is probably the least troublesome).

但是,CLR 要求您使用 C++/CLI 对 C++ 语言的扩展,因此从本质上讲,您需要学习一些额外的语言特性才能使用它.这样做可以为您提供许多额外功能",例如访问 .net 库、完整的垃圾回收等.

However, CLR requires you to use the C++/CLI extensions to the C++ language, so you'll, in essense, need to learn some extra language features in order to use this. Doing so gives you many "extras," such as access to the .net libraries, full garbage collection, etc.

ATL &MFC 在两者之间做出决定有点棘手.我建议您参考 MSDN 的选择页面为了在他们之间做出决定.ATL/MFC 的好处是您不需要 .NET 框架,只需安装 VC/MFC 运行时即可进行部署.

ATL & MFC are somewhat trickier to decide between. I'd refer you to MSDN's page for choosing in order to decide between them. The nice thing about ATL/MFC is that you don't need the .NET framework, only the VC/MFC runtimes to be installed for deployment.

直接使用 Win32 提供最小的可执行文件,具有最少的依赖项,但需要编写更多的工作.您的帮助程序库数量最少,因此您编写的代码更多.

Using Win32 directly provides the smallest executables, with the fewest dependencies, but is more work to write. You have the least amount of helper libraries, so you're writing more of the code.

这篇关于我如何决定是否为新的 C++ 项目使用 ATL、MFC、Win32 或 CLR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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