On Oct 18, 2:58 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Is the following error message correct?  It seems like system() ought
> to be in the ::std namespace.  What am I missing?
>
>     // main.cc
>     #include <cstdlib>
>     namespace system { }
>
>     $ g++ -ansi -pedantic -Wall -c main.cc
>     main.cc:3: error: 'namespace system { }' redeclared as different
> kind of symbol
>     /usr/include/stdlib.h:738: error: previous declaration of 'int
> system(const char*)'
>     make: *** [main.o] Error 1
>
> My current work-around is an unnamed "wrapper" namespace:
>
>     namespace { namespace system { } }

This behaviour is alloweb by the Standard.

In the section [headers] paragraph 4 of the current draft we read:

"Except as noted in clauses 18 through 27 and Annex D the contents of
each header cname shall be the same as that of
the corresponding header name.h, as specified in the Standard C99
Library (1.2) or the C Unicode TR, as appropriate, as
if by inclusion. In the C++ Standard Library, however, the
declarations (except for names which are defined as macros
in C) are within namespace scope (3.3.5) of the namespace std. It is
unspecified whether these names are first declared
within the global namespace scope and are then injected into namespace
std by explicit using-declaration s (7.3.3)."

That last sentence means the compiler is allowed to declare these
names in the global namespace.

I don't have the current Standard around to check if the same language
is in place, but I believe it to be so.

--
 Pedro Lamarão

_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to