After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 449016 - Prevent C++ keyword clashes
Prevent C++ keyword clashes
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
2.11.x
Other Linux
: Normal normal
: ---
Assigned To: Mathias Hasselmann (IRC: tbf)
Johan (not receiving bugmail) Dahlin
Depends on:
Blocks:
 
 
Reported: 2007-06-19 06:20 UTC by Mathias Hasselmann (IRC: tbf)
Modified: 2007-07-02 22:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Create test for finding C++ keywords in public header files (1.89 KB, patch)
2007-06-19 07:32 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review
Extend the C++ keyword test to include internal GDK headers. (6.46 KB, patch)
2007-06-19 18:03 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review
Restore G_BEGIN_DECLS at the top of this file to make C++ compilers happy. (1.28 KB, patch)
2007-06-19 18:04 UTC, Mathias Hasselmann (IRC: tbf)
committed Details | Review
Create test for finding C++ keywords in public header files (2.60 KB, patch)
2007-06-22 20:46 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review
Extend the C++ keyword test to include internal GDK headers. (7.78 KB, patch)
2007-06-22 20:46 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review

Description Mathias Hasselmann (IRC: tbf) 2007-06-19 06:20:48 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.
Comment 1 Mathias Hasselmann (IRC: tbf) 2007-06-19 07:32:10 UTC
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\/&>/'
Comment 2 Behdad Esfahbod 2007-06-19 13:32:11 UTC
It should include gdk backends (directfb, x11, etc) too.
Comment 3 Mathias Hasselmann (IRC: tbf) 2007-06-19 14:25:58 UTC
(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?
Comment 4 Behdad Esfahbod 2007-06-19 14:56:07 UTC
Only include the enabled backend.  See pango/tests/cxx-test.C
Comment 5 Mathias Hasselmann (IRC: tbf) 2007-06-19 18:03:43 UTC
Created attachment 90285 [details] [review]
Extend the C++ keyword test to include internal GDK headers.
Comment 6 Mathias Hasselmann (IRC: tbf) 2007-06-19 18:04:13 UTC
Created attachment 90286 [details] [review]
Restore G_BEGIN_DECLS at the top of this file to make C++ compilers happy.
Comment 7 Mathias Hasselmann (IRC: tbf) 2007-06-22 20:46:23 UTC
Created attachment 90496 [details] [review]
Create test for finding C++ keywords in public header files
Comment 8 Mathias Hasselmann (IRC: tbf) 2007-06-22 20:46:49 UTC
Created attachment 90497 [details] [review]
Extend the C++ keyword test to include internal GDK headers.
Comment 9 Matthias Clasen 2007-07-02 22:56:24 UTC
This was committed a while ago.