GNOME Bugzilla – Bug 155304
pygobject.h cannot be included in C++ programs
Last modified: 2006-01-09 14:12:22 UTC
install pygtk (debian sid 2.4) try to compile the file: //test.cpp #include <cstring> #include <cerrno> #include <cstdio> #include <iostream> #include <cmath> #include <utility> #include <pygobject.h> int main() { std::cout << "hello gtk" << std::cout; } I obtain the error: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I/usr/include/pygtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/python2.3 -c test.cpp In file included from /usr/include/python2.3/Python.h:8, from /usr/include/pygtk-2.0/pygobject.h:5, from test.cpp:8: /usr/include/python2.3/pyconfig.h:856:1: warning: "_POSIX_C_SOURCE" redefined In file included from /usr/include/string.h:26, from /usr/include/c++/3.3/cstring:51, from test.cpp:1: /usr/include/features.h:131:1: warning: this is the location of the previous definition In file included from test.cpp:8: /usr/include/pygtk-2.0/pygobject.h:140: error: parse error before `typename' /usr/include/pygtk-2.0/pygobject.h:147: error: parse error before `typename' I'm using gcc-3.3.5: > gcc -v Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.5 (Debian 1:3.3.5-1)
Problem was that the parameter 'typename' is a C++ keyword. Just in case, I also added G_BEGIN_DECLS / G_END_DECLS http://cvs.gnome.org/viewcvs/gnome-python/pygtk/gobject/pygobject.h?r1=1.44&r2=1.45&diff_format=u
*** Bug 156341 has been marked as a duplicate of this bug. ***
*** Bug 301803 has been marked as a duplicate of this bug. ***