Bug#191737: acknowledged by developer (Re: Bug#191737: xinerama.h is missing extern C { for C++ compiling)
>> Daniel Stone <dstone@kde.org> writes:
> Yes, but it's not Xinerama's problem, and I don't see why it should be
> bending over backwards to support people using it from another language.
> I certainly won't be including this patch in my tree.
Because that's the polite way of coding C header files. You can't be
so shortsighted to assume that the library is never going to be used by
C++ programs (or any other languaje that can interface with C for that
matter), specially when one of the reasons for choosing C over C++ is
that the former is more interoperable than the later. Quoting
Stroustrup:
C programmers typically assume any C header can be used from a C++
program. This assumption has largely been true (after someone adds
suitable extern "C" directives), though headers that use C++
keywords as identifiers have been a constant irritant to C++
programmers (and sometimes a serious practical problem).
[...]
The ability to share header files is an important aspect of C and
C++ culture and a key to performance of programs using both
languages. If the header files are kept compatible, C and C++
programs can call libraries implemented in "the other language" with
no data conversion overheads and no (or very minimal) call overhead.
Granted, C++ programmers _are_ snottish in this respect, but there's no
good reason for C programmers to behave the same way.
Historically X has been a bad citizen in this general regard (True,
False, Bool, Status, DirectColor and a lot of others pollute the
namespace) but it does the right thing when it comes to extern "C".
You just have to add a simple _XFUNCPROTOBEGIN / _XFUNCPROTOEND to the
headers.
Marcelo
Reply to: