Hi ...
While getting my cmake plugin working I got this strange error while compiling.
The idea in the code is to get the project base dir, by accessing the "app" instance and then the "project" pointer. But the compiler provide me with some strange output.
The code is :
255 : /* open the current make file */ 256 : if( app->project != NULL ) 257 : base_path = app->project->base_path;
This is the error :
cmakeprj.c:256: error: 'GeanyApp' has no member named 'geany_data'
Are there anyway else I need getting this path ?
Also, how do I get noted if the project is changed or saved ?
/BL
On Dec 24, 2007 4:15 PM, Bo Lorentsen bl@lue.dk wrote:
While getting my cmake plugin working I got this strange error while compiling.
cmakeprj.c:256: error: 'GeanyApp' has no member named 'geany_data'
I think this is because there is already a macro named "project" in the pluginmacros.h file: #define project app->project
So when you say app->project, the preprocessor expands it to app->app->project, which causes the error you are seeing.
Maybe try this instead:
256 : if( project != NULL ) 257 : base_path = project->base_path;
Also, how do I get noted if the project is changed or saved ?
Your callbacks will be automatically registered if you do something like this:
void my_proj_open(GObject *obj, GKeyFile *config, gpointer user_data) { g_print("Project opened!") }
void my_proj_saved(GObject *obj, GKeyFile *config, gpointer user_data) { g_print("Project saved!") }
void my_proj_close(GObject *obj, GKeyFile *config, gpointer user_data) { g_print("Project closed!") }
GeanyCallback geany_callbacks[] = { {"project-open", (GCallback) &my_proj_open, TRUE, NULL}, {"project-save", (GCallback) &my_proj_save, TRUE, NULL}, {"project-close", (GCallback) &my_proj_close, TRUE, NULL}, {NULL, NULL, FALSE, NULL} };
Hope this helps,
- Jeff
On Dec 25, 2007 4:06 AM, Bo Lorentsen bl@lue.dk wrote:
Jeff Pohlmeyer wrote:
I think this is because there is already a macro named "project" in the pluginmacros.h file:
Has not been coding C for a while, so its easy to forget the preprocessor.
Don't feel bad, the reason I know this is because it bite me just yesterday :-)
Thanks !
You're welcome,
- Jeff
Jeff Pohlmeyer wrote:
On Dec 25, 2007 4:06 AM, Bo Lorentsen bl@lue.dk wrote:
Jeff Pohlmeyer wrote:
I think this is because there is already a macro named "project" in the pluginmacros.h file:
Has not been coding C for a while, so its easy to forget the preprocessor.
Don't feel bad, the reason I know this is because it bite me just yesterday :-)
Thanks, that helped :-)
Also, normally when I made preprocessor macros before I user pure capital names to make then stand out from the rest of the names ! This too is a nice excuse :-)
/BL
Hi
On Mon, Dec 24, 2007 at 11:15:36PM +0100, Bo Lorentsen wrote:
Hi ...
While getting my cmake plugin working I got this strange error while compiling.
The idea in the code is to get the project base dir, by accessing the "app" instance and then the "project" pointer. But the compiler provide me with some strange output.
The code is :
255 : /* open the current make file */ 256 : if( app->project != NULL ) 257 : base_path = app->project->base_path;
This is the error :
cmakeprj.c:256: error: 'GeanyApp' has no member named 'geany_data'
That is simple. In pluginmacros.h
#define app geany_data->app #define doc_array geany_data->doc_array #define prefs geany_data->prefs #define project app->project
so app->project transform to:
geany_data->app->geany_data->app->project
use "project" instead of "app->project"
Also, how do I get noted if the project is changed or saved ?
see plugindata.h callbacks "project-open", "project-save", "project-close".
Best regards, Yura Siamashka
Yura Siamashka wrote:
#define app geany_data->app #define doc_array geany_data->doc_array #define prefs geany_data->prefs #define project app->project
I did not notice these, have not been working with C preprocessor for a while now, so this is easy to forget :-)
geany_data->app->geany_data->app->project
Yeps, this makes sense !
use "project" instead of "app->project"
Done, and it works, too !
Also, how do I get noted if the project is changed or saved ?
see plugindata.h callbacks "project-open", "project-save", "project-close".
Hmm, I take a look again, thanks.
/BL
On Tue, 25 Dec 2007 11:31:52 +0100, Bo Lorentsen bl@lue.dk wrote:
Yura Siamashka wrote:
#define app geany_data->app #define doc_array geany_data->doc_array #define prefs geany_data->prefs #define project app->project
I did not notice these, have not been working with C preprocessor for a while now, so this is easy to forget :-)
geany_data->app->geany_data->app->project
Yeps, this makes sense !
use "project" instead of "app->project"
Done, and it works, too !
Also, how do I get noted if the project is changed or saved ?
see plugindata.h callbacks "project-open", "project-save", "project-close".
Hmm, I take a look again, thanks.
For an example see Nick's great signal example plugin (http://lists.uvena.de/pipermail/geany/2007-August/001570.html).
Sometime I'll put this into a plugin howto...
Regards, Enrico