Most of the documentation involving PLUGIN_HANDLE provides erroneous usage examples for the C++ implementation of a plugin.
The plugin_init() function is correct and returns a PLUGIN_HANDLE type (void*) containing a pointer to the main plugin class (in this example a DHT11*):
But then most of the other functions in the documentation take a PLUGIN_HANDLE* as parameter (void**) when it should in fact use a PLUGIN_HANDLE only. It is clearly visible that the input type is actually the same type as the one returned by plugin_init() when the input type is casted into DHT11* here:
All of the documentation involving this type needs to be reviewed: some functions may actually need PLUGIN_HANDLE* as an input, but most of them doesn't and must be fixed.
Sadly most of the existing plugins are based on those examples and do contain this erroneous implementation which is not raising any error because it is using the "jocker" void* type.
As an example in one of the plugins I reviewed this led to really messed up codes likes this one where you end up casting a PLUGIN_HANDLE into PLUGIN_HANDLE* which makes zero sense in term of pure C++:
Most of the documentation involving PLUGIN_HANDLE provides erroneous usage examples for the C++ implementation of a plugin.
The
plugin_init()
function is correct and returns aPLUGIN_HANDLE
type (void*
) containing a pointer to the main plugin class (in this example aDHT11*
):But then most of the other functions in the documentation take a
PLUGIN_HANDLE*
as parameter (void**
) when it should in fact use aPLUGIN_HANDLE
only. It is clearly visible that the input type is actually the same type as the one returned byplugin_init()
when the input type is casted intoDHT11*
here:All of the documentation involving this type needs to be reviewed: some functions may actually need
PLUGIN_HANDLE*
as an input, but most of them doesn't and must be fixed.Sadly most of the existing plugins are based on those examples and do contain this erroneous implementation which is not raising any error because it is using the "jocker"
void*
type.As an example in one of the plugins I reviewed this led to really messed up codes likes this one where you end up casting a
PLUGIN_HANDLE
intoPLUGIN_HANDLE*
which makes zero sense in term of pure C++: