Topic: <cfoo> vs <foo.h>


Author: sebor@my-deja.com
Date: 1999/12/30
Raw View
In article <385417A5.A21D5726@ihug.co.nz>,
  Ross Smith <ross.s@ihug.co.nz> wrote:
> If you include both <cfoo> and <foo.h> (where foo is one of the
standard
> C headers) in the same module, do we have any guarantee that this is
> harmless? I couldn't find any reference to this in the standard.
>

I haven't found anything either but it's definitely not easy to make it
work (although I don't see why it should be prohibited). We found that
it's almost impossible to do cleanly without cooperation from the C
library implementers. If <foo.c> is supposed to declare names in std in
addition to the global namespace (as suggested in LWG issue 143, version
1 or 2) either the C++ library must provide its own "wrapper" C headers
or the C library must be made C++ aware.

The problem with the former approach is that the native C headers are
often designed to declare only a subset of their names when #included
from other libc headers (glibc is one such lib). The C++ wrapper, which
is substituted for the C header during inclusion, must somehow know
which names have been declared and which have not (to prevent
referencing undeclared names in the using declarations). This might be
fine if you're writing and distributing both the C and the C++ libraries
but that's usually not the case.

Martin


Sent via Deja.com http://www.deja.com/
Before you buy.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Ross Smith <ross.s@ihug.co.nz>
Date: 1999/12/14
Raw View
If you include both <cfoo> and <foo.h> (where foo is one of the standard
C headers) in the same module, do we have any guarantee that this is
harmless? I couldn't find any reference to this in the standard.

--
Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
========================================================================
    "Be careful about using the following code -- I've only proven
    that it works, I haven't tested it."           -- Donald Knuth
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Jesse Weinstock" <jw8916@cnsvax.albany.edu>
Date: 1999/12/14
Raw View
if you include std headers, they have error checking up to wazoo for
duplicate use.  you should be ok including <cfoo> and <foo.h>




[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]