This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PLUGINS] Add 'extern "C"' wrappers to several header files



I would suggest that if you're building your plugin in C++, you either:

(1) build the entire compiler with a C++ compiler, or

No, that's wrong. If GCC is built with a C compiler, it should support both C and C++ plugins. If GCC is built with a C++ compiler, of course it should support C++ plugins only.


   (2) identify a well-defined interface to your plugin, e.g. the entry points
        and declare them with the C calling convention; and code the internals
        of your plugin in C++

That's a good interim plan.


You can do this: add a #define (via configure.ac) when building with --enable-build-with-cxx, like AC_DEFINE([GCC_BUILT_WITH_CXX]), and use

#include "config.h"
#if defined __cplusplus && !defined GCC_BUILT_WITH_CXX
extern "C" {
#endif

...

#if defined __cplusplus && !defined GCC_BUILT_WITH_CXX
}
#endif

By the way, I wonder if auto-host.h is installed; it should not if it is. A good cleanup to do would be to make a smaller version of config.in (call it plugin-config.in) with the (hopefully) few necessary macros, and install the file generated from it as auto-host.h.

Also, for better karma we may want to add an installcheck target that builds a plugin. Almost no one uses installcheck (except for Automake packages for example, where "make distcheck" invokes it), but it's a very good idea to have one.

(It goes without saying that implementing installcheck to run the full testsuite would also be a good idea).

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]