[Xcb] Bug#491554: missing extern "C" stanza for C++ use

Ulrich Eckhardt doomster at knuut.de
Sun Jul 20 05:16:33 PDT 2008


Package: libxcb-shape0-dev
Version: 1.1-1.1

The header file xcb/shape.h can't be used in C++ directly because it is 
missing the 

 #ifdef __cplusplus
 extern "C" {
 #endif

 #ifdef __cplusplus
 } // extern "C"
 #endif

wrappers. This causes linker errors, because to C and C++ the declarations in 
the headers declare different symbols. Note that this doesn't only affect the 
shape header, others are affected, too. I used

 for i in /usr/include/xcb/*; do
   grep 'extern "C"' $i >/dev/null || echo $i
 done

to find header files without the wrapper and it reported a few more from other 
XCB libraries:

 /usr/include/xcb/bigreq.h
 /usr/include/xcb/render.h
 /usr/include/xcb/shape.h
 /usr/include/xcb/shm.h
 /usr/include/xcb/xc_misc.h
 /usr/include/xcb/xcb_atom.h
 /usr/include/xcb/xcb_renderutil.h
 /usr/include/xcb/xcbxlib.h
 /usr/include/xcb/xproto.h

Note: xproto.h might be a false positive, because it is included by xcb.h 
inside its extern "C" wrapper. Further, you can't use it on its own anyway 
due to its circular dependency on xcb.h. xproto.h defines its include-guard 
macros and then includes xcb.h, which in turn includes xproto.h a second 
time. However, the include guards make that a no-op so lateron when using 
parts of xproto.h it fails. I don't think that file should be included on its 
own but only by xcb.h, so it should generate a suitable error and the 
#inlude "xcb.h" should be removed from it.


Workaround:

 extern "C" {
 #include <xcb/shape.h>
 }

Uli




More information about the Xcb mailing list