Strangest Error I Have Ever Seen, a.k.a. ) *
c, gobject, gtk
Solution
`CharcoalApp` is not declared in `global.h`. Suppose you are including `CharcoalApp.h` in your C file:
- CharcoalApp.h is read up to #include "global.h"
- global.h is included
- Error: expected ')' before '*' token
You should rearrange your header files properly or use a forward declaration (although I don't think is needed in this case).
There are many solutions:
- the proper way: include CharcoalApp.h from global.h, not the reverse;
- move `typedef struct _CharcoalApp CharcoalApp;` before `#include "global.h" in CharcoalApp.h;
- remove `#include "global.h"` from CharcoalApp.h and include them in the proper order (global.h last).
Problem
I'm writing this awesome application, at least I think it awesome, in C with the magnificent blend of GObject and after a while I start getting this very, extremely strange error. I also believe to have noticed it not appearing always. However this might just be the IDE's fault. Anyhow... GCC, apparently, complains: expected ')' before '*' token; this happens in a header file. This is that very same header file. ``` #pragma once #include "global.h" #include "CharcoalApp.h" GtkListStore *WebsitesListStore; // that error is reported for this line void charcoal_websites_list_initialize(CharcoalApp *app); ``` As far as I can see, this comes from the `CharcoalApp *app` parameter for that function. Because I cannot really understand why this error is happening, I'll include the `CharcoalApp.h` file. `global.h` is a very simple header file that carries the main dependencies, mainly GLib, GObject, GThread, GTK+, WebKit and other. CharcoalApp.h ``` #ifndef __CHARCOAL_APP_H__ #define __CHARCOAL_APP_H__ #include "global.h" #include "CharcoalDB.h" #include "CharcoalWindow.h" #include "CharcoalWebsitesList.h" G_BEGIN_DECLS #define CHARCOAL_TYPE_APP (charcoal_app_get_type()) #define CHARCOAL_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHARCOAL_TYPE_APP, CharcoalApp)) #define CHARCOAL_APP_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHARCOAL_TYPE_APP, CharcoalApp const)) #define CHARCOAL_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHARCOAL_TYPE_APP, CharcoalAppClass)) #define CHARCOAL_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHARCOAL_TYPE_APP)) #define CHARCOAL_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CHARCOAL_TYPE_APP)) #define CHARCOAL_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHARCOAL_TYPE_APP, CharcoalAppClass)) typedef struct _CharcoalApp CharcoalApp; typedef struct _CharcoalAppClass CharcoalAppClass; typedef struct _CharcoalAppPrivate CharcoalAppPrivate; struct _CharcoalApp { GObject parent; CharcoalAppPrivate *priv; GtkBuilder *ui; CharcoalDB *db; // toplevels GtkWidget *CharcoalWindow; }; struct _CharcoalAppClass { GObjectClass parent_class; }; GType charcoal_app_get_type(void) G_GNUC_CONST; CharcoalApp *charcoal_app_new(void); void charcoal_app_quit(CharcoalApp *app); G_END_DECLS #endif /* __CHARCOAL_APP_H__ */ ``` Thank you for your help!