User forums > Help
GTK+ with C - code completation not for all functions
ollydbg:
--- Quote from: Meiner on February 14, 2012, 02:53:35 pm ---Thanks for your answer. I attached the main header file gtk.h and the gtkwindow.h which contains gtk_windows_new().
When there is a need I can give more examples or header files.
--- End quote ---
Here, the name should be: gtk_window_new NOT gtk_windows_new, So, please be more "careful".
Now, the header file contains some code snippet:
--- Code: ---#ifdef G_OS_WIN32
/* Reserve old names for DLL ABI backward compatibility */
#define gtk_window_set_icon_from_file gtk_window_set_icon_from_file_utf8
#define gtk_window_set_default_icon_from_file gtk_window_set_default_icon_from_file_utf8
#endif
GType gtk_window_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_window_new (GtkWindowType type);
void gtk_window_set_title (GtkWindow *window,
const gchar *title);
--- End code ---
But here G_OS_WIN32 is not defined. So, if you have enable the codecompletion's option:
Parse preprocessor directives, which means the code:
--- Code: ---#ifdef G_OS_WIN32
--- End code ---
will be evaluated, and it return "false", so this branch does not parsed.
Many solutions:
1, find where G_OS_WIN32 was defined, suppose it was defined in "aaa.h", then you can add "aaa.h" to priority headers set, so the "aaa.h" will have a more precedence, and when parsing gtkwindow.h, this preprocessor directive will become true.
2, disable the option: Parse preprocessor directives in CC's option
3, maybe, you can use gcc's preprocessor feature, like gcc -E to generate some dummy header files, which contains all the preprocessed texts, and put such dummy header file in your projects.
Note: The parser in our CC does not do a full parsing like a compiler did. A full parsing contains too many things for a single translate unit, like it should expand all the header files and evaluate and expand all the macro expansions. Our parser just only parser every file once.
Meiner:
--- Quote from: ollydbg on February 14, 2012, 04:02:38 pm ---
--- Quote from: Meiner on February 14, 2012, 02:53:35 pm ---Thanks for your answer. I attached the main header file gtk.h and the gtkwindow.h which contains gtk_windows_new().
When there is a need I can give more examples or header files.
--- End quote ---
Here, the name should be: gtk_window_new NOT gtk_windows_new, So, please be more "careful".
--- End quote ---
I'm sorry for that. Perhaps I should not post while sitting in a lecture ;).
--- Quote from: ollydbg on February 14, 2012, 04:02:38 pm ---Many solutions:
1, find where G_OS_WIN32 was defined, suppose it was defined in "aaa.h", then you can add "aaa.h" to priority headers set, so the "aaa.h" will have a more precedence, and when parsing gtkwindow.h, this preprocessor directive will become true.
2, disable the option: Parse preprocessor directives in CC's option
3, maybe, you can use gcc's preprocessor feature, like gcc -E to generate some dummy header files, which contains all the preprocessed texts, and put such dummy header file in your projects.
--- End quote ---
I tried the second method first (now with Nightly Build 7789), but I have a problem. I can't unselect the option "Parse preprocessor directives". Everytime I unchecked the box leaving the configure editor the option resets automatically. There is no write protection on the config files and it does not work on a second computer with an older C::B Nightly Build either. Is there another protection for the configuration?
I also tried the first suggestion with a reparse of the whole project, but there is no change in the CC behaviour.
EDIT: I realized that I can change the "Parse preprocessor directives" option only when no project is open. Although then there is the error "No active project found. Settings not saved." it seems that the settings are saved. When there is a project open the option resets itself everytime. However, deactivating the option seems to change nothing (with regard to my problem).
Jenna:
I just tried it on linux with latest trunk.
I can see it in symbols browser, but autocomplete does not work.
ollydbg:
This is what I did to solve this problem:
I have see that I should have a macro defined, so I did:
1, create a dummy header file under my project root folder, and named "aaa.h".
aaa.h contains only one line:
--- Code: ---#define G_OS_WIN32 1
--- End code ---
2, add this file to project. Also, add "aaa.h" to priority headers list in CC option.
3, Add one token replacement(replace GSEAL(X) to X) in CC option.
See: http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#AAAAA_-.3E_.2A
--- Code: ---GSEAL -> *
--- End code ---
Otherwise, this macro will let our parser fail in parsing such statement in "gtkwindow.h"
--- Code: ---struct _GtkWindow
{
GtkBin bin;
gchar *GSEAL (title);
gchar *GSEAL (wmclass_name);
gchar *GSEAL (wmclass_class);
gchar *GSEAL (wm_role);
--- End code ---
So, the parser see it like below:
--- Code: ---
struct _GtkWindow
{
GtkBin bin;
gchar *title;
gchar *wmclass_name;
gchar *wmclass_class;
gchar *wm_role;
--- End code ---
Now, it works Here (windowsXP, c::b trunk) screen shot below:
PS: it looks like the priority header change will take effect when I restart C::B. (I will look into in the future :))
Meiner:
Thank you very much for your help :D , the token replacement works wonders.
But I got the warning "G_OS_WIN32" redefinend" (glibconfig.h, line 163) when adding such a dummy header file. Moreover I don't see any changes, so I think it makes no difference whether adding the header file or not. Did I miss someting?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version