Rene Rebe <r...@rocklinux-consulting.de> writes: > Hi, > > On: Mon, 12 Jul 2004 20:17:27 +0200, > Mattias Ellert <mattias.ell...@tsl.uu.se> wrote: > >> >>Is there a good reason why the installed sane.h misses the usual >> >>header lines needed for compilation with C++? >> > >> > Well, it's a C and not a C++ header and these #ifdefs are ugly :-) >> >> If you put them in the header file you only need them once. Since they >> are not in the header files you have to do >> >> extern "C" { >> #include <sane/sane.h> >> } >> >> in every c++ file. I think this is more "ugly". Having the extern >> declaration in one single place (i.e. in the header file) makes so much >> more sense than having to put in in every single file where you include it. >> >> You don't have to do this kind of hack for normal system header files. >> Almost all other header files have the extern "C" declaration (or the >> equivalent __BEGIN_DECLS __END_DECLS pair). > > Yes - ack. This is the way nearly any other system header is prepared ... > >> > Isn't it a better solution to use the extern "C" when including the >> > file in the C++ .C code if you really want to use sane.h in C++? Or do >> > we get trouble this way because it includes the structs? >> >> I think having them in the header file is "the better solution". > > Sure - I just quick fixed it in my example app by doing so ... But I > just wanted to note it publicly that we miss it ... > > I fully agree that C/C++ users assume including "some random" header > will just work. > > I can only imagine one drawback - that current C++ projects (kooka) > that include the "defect" header that have a private fix by > surrounding the inclusion with the extern "C" declaration could > fail. But at least with gcc 3.4.1 this is not the case - just tested > it (I guess the old ones accept it, too).
Nested extern "C" declarations work with at least gcc 3.2 and later. I do seem to recall that it also works with 2.97 but that's just a vague recollection. >> >>May I just commit them to CVS? >> >> I would say YES. > > Any other votes ,-)? Please commit. -- Olaf Meeuwissen EPSON KOWA Corporation, PF1 FSF Associate Member #1962 sign up at http://member.fsf.org/ GnuPG key: 6BE37D90/AB6B 0D1F 99E7 1BF5 EB97 976A 16C7 F27D 6BE3 7D90 Penguin's lib! -- I hack, therefore I am -- LPIC-2