GNOME Bugzilla – Bug 449016
Prevent C++ keyword clashes
Last modified: 2007-07-02 22:56:24 UTC
> In the new header file of gtkbuilder, it use typename as parameter's > name, typename is a keyword of C++, so when compile C++ application such > as gtkmm, thunderbird, it will cause compile error, so it is better to > change it to another name like gtypename. > > Regards. > younker Suggestion was made on gtk-devel to prevent such situations in the future by introducing an automated test checking the public header files for C++ keywords.
Created attachment 90258 [details] [review] Create test for finding C++ keywords in public header files That's how this test could look like. Instead of just including <gtk/gtk.h> sed could be used to process Makefile.am files and include all public and semi private header files (example for the "gtk" folder): sed -n -e ':merge /\\$/N' -e 's/\\\n//g' -e 't merge' \ -e 's/^\w\+\(public\|semi_private\)_h_sources\s*=\s*//p' gtk/Makefile.am | sed -e 's/\s\+/\n/g' | sed -e 's/.*/#include <gtk\/&>/'
It should include gdk backends (directfb, x11, etc) too.
(In reply to comment #2) > It should include gdk backends (directfb, x11, etc) too. > Yes makes sense, but how to prevent this kind of errors? In file included from testkeywords.cxx:6: ../gdk/directfb/gdkdirectfb.h:37:22: error: directfb.h: No such file or directory In file included from testkeywords.cxx:14: ../gdk/quartz/gdkquartz.h:4:27: error: AppKit/AppKit.h: No such file or directory In file included from ../gdk/quartz/gdkprivate-quartz.h:28, Guess only linking in those headers we know works arround the goal of having a reliable distcheck. So shall I put fake versions of those platform headers into the test folder and redirect g++ to it using an -I switch?
Only include the enabled backend. See pango/tests/cxx-test.C
Created attachment 90285 [details] [review] Extend the C++ keyword test to include internal GDK headers.
Created attachment 90286 [details] [review] Restore G_BEGIN_DECLS at the top of this file to make C++ compilers happy.
Created attachment 90496 [details] [review] Create test for finding C++ keywords in public header files
Created attachment 90497 [details] [review] Extend the C++ keyword test to include internal GDK headers.
This was committed a while ago.