Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's safe for a C++ plug-in system?

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.

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.

Off the top of my head, here are some C++ features I can think of, with what I think is the answer:

  • vtable layout, to use objects through abstract classes? (yes)
  • built-in types, pointers? (yes)
  • structs, unions? (yes)
  • exceptions? (no)
  • extern "C" functions? (yes)
  • stdcall non-extern "C" functions with built-in parameter types? (yes)
  • non-stdcall non-extern "C" functions with user-defined parameter types? (no)

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.

Carl

like image 600
Carl Seleborg Avatar asked Sep 04 '08 08:09

Carl Seleborg


People also ask

Why are non permitted plugs such as the German Schuko plug unsafe for use in Singapore NTU?

Furthermore, while 'Schuko' plugs may come with earthing strips located on their sides, they are not safe for use in Singapore as the earthing strips cannot make contact with the earth contact of a local mains socket.

Can I use 250v in Singapore?

You can use all your equipment in Singapore if the outlet voltage in your own country is between 220V-240V. This is the case in most of Europe, Australia, the United Kingdom and most countries in Africa and Asia.

Which countries use UK 3 pin plugs?

This electrical socket is common in: GB, Ireland, Cyprus, Malta, Malaysia, Singapore, Hong Kong, ... The Type G plug has three rectangular pins in a triangular pattern and includes a fuse (usually a 3A fuse for smaller appliances, such as computers, or a 13A fuse for larger appliances, such as heaters).


2 Answers

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.

like image 106
Serge Avatar answered Sep 22 '22 22:09

Serge


You might also want to consider replacing the conventional plugin interface by a scripting interface. There are some very good bindings for several scripting languages in C/C++ that have already solved your problem. It might not be a bad idea to build on top of them. For example, have a look at Boost.Python.

like image 33
Konrad Rudolph Avatar answered Sep 20 '22 22:09

Konrad Rudolph