[cfe-dev] Value of __cplusplus in GNU modes

Eli Friedman eli.friedman at gmail.com
Tue May 8 11:01:06 PDT 2012


On Tue, May 8, 2012 at 9:47 AM, Dmitri Shubin <sbn at tbricks.com> wrote:
> On 04.05.2012 19:21, Chris Jefferson wrote:
>> For many years, it was solaris in particular which was holding up GCC
>> defining the correct value for __cplusplus. This has been fixed in gcc
>> by adding a bunch of 'fix includes'. I don't know exactly what the
>> issues were, or how much clang cares about solaris, but that is
>> probably the best place to check issues. Chris
>
> When I tried clang TOT (156374) on Solaris 10 I got error which can be
> shown by the following minimized source:
>
> $ cat -n a.cpp
>      1  #include <unistd.h>
>      2  #include <stdio.h>
> $ ./build-clang/Release/bin/clang++ -c a.cpp
> In file included from a.cpp:2:
> /usr/include/stdio.h:85:12: error: target of using declaration conflicts
> with declaration already in scope
> using std::rename;
>            ^
> /usr/include/iso/stdio_iso.h:190:12: note: target of using declaration
> extern int      rename(const char *, const char *);
>                 ^
> /usr/include/unistd.h:449:12: note: conflicting declaration
> extern int rename(const char *, const char *);
>            ^
> 1 error generated.
>
> This can be minimized even further:
>
> $ cat -n b.cpp
>      1  extern "C" {
>      2
>      3  namespace std {
>      4  extern int rename(const char *, const char *);
>      5  }
>      6
>      7  }
>      8
>      9  using std::rename;
>     10
>     11  extern "C" {
>     12  extern int rename(const char *, const char *);
>     13  }
> $ ./build-clang/Release/bin/clang++ -c b.cpp
> b.cpp:12:12: error: declaration conflicts with target of using
> declaration already in scope
> extern int rename(const char *, const char *);
>            ^
> b.cpp:4:12: note: target of using declaration
> extern int rename(const char *, const char *);
>            ^
> b.cpp:9:12: note: using declaration
> using std::rename;
>            ^
> 1 error generated.
>
> Both g++ 4.7 and Sun C++ 5.11 compile it without errors.
> Is it clang bug or other compilers are more liberal.

Definitely a bug.

-Eli




More information about the cfe-dev mailing list