Topic: namespace { #include }: no ! (Was: hide C-header files throw NAMESPACES)


Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/10/30
Raw View
Alastair J. Houghton wrote:
>
> Valentin Bonnard <Bonnard.V@wanadoo.fr> wrote in message
> news:38168787.FA7@wanadoo.fr...

> > Never ever include a file inside any C++ construct
> > (that is, include them at top-level) [1].

> Out of interest, do you think this is more acceptable
> if the headers are wrapped with an extern "C"

No. Instead, change the header themselves.

--

Valentin Bonnard
---
[ 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: "Alastair J. Houghton" <ajh8@doc.ic.ac.uk>
Date: 1999/10/28
Raw View
Valentin Bonnard <Bonnard.V@wanadoo.fr> wrote in message
news:38168787.FA7@wanadoo.fr...
> Raphael Bossek wrote:
>
> > namespace OLDLIB {
> >    #include "mm.h"
> >    #include "mha.h"
> > }
>
> Never ever include a file inside any C++ construct
> (that is, include them at top-level) [1].

[snip]

Out of interest, do you think this is more acceptable
if the headers are wrapped with an extern "C" (yes,
I know this doesn't mean that they are processed as
C code - but it does prevent name mangling problems
created by the namespace)?

Thanks,

Alastair Houghton
---
[ 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: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/10/27
Raw View
Raphael Bossek wrote:

> namespace OLDLIB {
>    #include "mm.h"
>    #include "mha.h"
> }

Never ever include a file inside any C++ construct
(that is, include them at top-level) [1].

Headers are written to be processed at top-level;
doing otherwise may work by accident, but in general
it's undefined behaviour.

[1] except maybe if you know, control and own the
included file and you want to play nasty tricks

--

Valentin Bonnard
---
[ 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              ]