C++ 中的插件系统很难,因为 ABI 没有正确定义,并且每个编译器(或其版本)都遵循自己的规则.然而,Windows 上的 COM 表明可以创建一个最小的插件系统,允许使用不同编译器的程序员使用简单的界面为宿主应用程序创建插件.
Plug-in systems in C++ are hard because the ABI is not properly defined, and each compiler (or version thereof) follows its own rules. However, COM on Windows shows that it's possible to create a minimal plug-in system that allows programmers with different compilers to create plug-ins for a host application using a simple interface.
让我们务实一点,把在这方面不是很有帮助的 C++ 标准暂时搁置一旁.如果我想为 Windows 和 Mac(以及可选的 Linux)编写一个支持 C++ 插件的应用程序,并且如果我想为插件作者提供相当多的编译器选择(比如不到 2 年的 Visual C++ 版本)、GCC 或 Intel 的 C++ 编译器),我可以指望 C++ 的哪些特性?
Let's be practical, and leave the C++ standard, which is not very helpful in this respect, aside for a minute. If I want to write an app for Windows and Mac (and optionally Linux) that supports C++ plug-ins, and if I want to give plug-in authors a reasonably large choice of compilers (say less than 2 year old versions of Visual C++, GCC or Intel's C++ compiler), what features of C++ could I count on?
当然,我假设插件是为特定平台编写的.
Of course, I assume that plug-ins would be written for a specific platform.
在我的脑海里,这里有一些我能想到的 C++ 特性,我认为答案是:
Off the top of my head, here are some C++ features I can think of, with what I think is the answer:
如果您能分享在该领域的任何经验,我将不胜感激.如果您知道任何具有 C++ 插件系统的中等成功的应用程序,那也很酷.
I would appreciate any experience you have in that area that you could share. If you know of any moderately successful app that has a C++ plug-in system, that's cool too.
卡尔
Dr Dobb's Journal 有一篇文章 构建您自己的插件框架:第 1 部分 这是关于该主题的非常好的阅读.这是一系列文章的开始,涵盖了 C/C++ 跨平台插件框架的架构、开发和部署.
Dr Dobb's Journal has an article Building Your Own Plugin Framework: Part 1 which is pretty good reading on the subject. It is the start of a series of articles which covers the architecture, development, and deployment of a C/C++ cross-platform plugin framework.
这篇关于对于 C++ 插件系统来说什么是安全的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!