[PATCH] Simplify plugin writing

David Faure faure at kde.org
Mon Nov 5 17:22:07 GMT 2007

On Monday 05 November 2007, Will Stephenson wrote:
> When defining a plugin we use K_PLUGIN_FACTORY and K_EXPORT_PLUGIN macros to 
> define its plugin factory and export it as a plugin.  K_EXPORT_PLUGIN is 
> defined in kpluginloader.h.  I find #including this counterintuitive as a 
> plugin author, and the compiler error when this is omitted had me mystified.  
+2 :)
Same experience here.

> The attached patch simplifies plugin definition to just #include 
> <kpluginfactory.h> and using the macros, by moving the definition of 
> K_EXPORT_PLUGIN to a separate file, kexportplugin.h, which is included from 
> both *loader and *factory headers.  
Looks good.

> I have rebuilt kdelibs and kopete with  
> this change and both build correctly; is anyone aware of more subtle use of 
> plugins that it may break?
No but it would be good to update the unit test (klibloadertest4_module.cpp) to see if it
compiles without <kpluginfactory.h> now, as intended :)

David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

More information about the kde-core-devel mailing list