[Geany] Plugin keybindings support in SVN
Jeff Pohlmeyer
yetanothergeek at xxxxx
Fri Mar 14 13:51:34 UTC 2008
Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> Jeff Pohlmeyer <yetanothergeek at gmail.com> wrote:
> > I can now create the name and label strings dynamically,
> > but I get those "discards qualifiers" messages when I
> > compile with warnings turned on.
>
> Can you show some example code that produces the warnings, and your
> warning flags (I use at least -Wall and -Wextra)?
Here is an example that should give you a general idea of
what I am trying to do. Note that I use "group" here instead
of plugin_key_group[1] just to shorten lines for email...
/***************************/
#include "geany.h"
#include "keybindings.h"
#include "plugindata.h"
#include "pluginmacros.h"
PluginFields *plugin_fields;
VERSION_CHECK(48)
PLUGIN_INFO("ConstChar", "Warning", "0", "Jeff")
KeyBindingGroup plugin_key_group[1];
#define group plugin_key_group[1]
void init(GeanyData *data)
{
guint count=10;
guint i;
group.count=count;
group.keys=g_new0(KeyBinding, count);
for (i=0; i<count; i++)
{
group.keys[i].name=g_strdup_printf("key_%d",i);
group.keys[i].name=g_strdup_printf("Label %d",i);
}
}
/* Destroy widgets */
void cleanup(void)
{
guint i;
for (i=0; i<group.count; i++)
{
g_free(group.name);
g_free(group.label);
}
g_free(group.keys);
}
/***************************/
The problem comes with calling g_free() on the const char* .
You can get around it with a cast, but the warning comes back
if you compile with -Wcast-qual .
- Jeff
More information about the Users
mailing list