[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" {

 #ifdef __cplusplus
 } // extern "C"

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

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


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.


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


More information about the Xcb mailing list