[oi-dev] one more question about headers

Alexander Pyhalov alp at rsu.ru
Fri Jun 28 22:20:11 UTC 2013


Hello all.
I continue to experiment with compilers and now I've found one 
interesting case. It works with g++, but breaks with clang++.

The code is (it uses g++ 4.7 headers):
#include <cmath>
#include <cstdlib>

int main ()
{

return 0;
}

This leads to

In file included from test1.cpp:2:
In file included from /usr/gcc/4.7/include/c++/4.7.3/cstdlib:66:
/usr/include/stdlib.h:52:12: error: target of using declaration 
conflicts with declaration already in scope
using std::atof;
^
/usr/include/iso/stdlib_iso.h:124:15: note: target of using declaration
extern double atof(const char *);
^
/usr/include/floatingpoint.h:204:15: note: conflicting declaration
extern double atof __P((const char *));
^
In file included from test1.cpp:2:
In file included from /usr/gcc/4.7/include/c++/4.7.3/cstdlib:66:
/usr/include/stdlib.h:71:12: error: target of using declaration 
conflicts with declaration already in scope
using std::strtod;
^
/usr/include/iso/stdlib_iso.h:157:15: note: target of using declaration
extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
^
/usr/include/floatingpoint.h:205:15: note: conflicting declaration
extern double strtod __P((const char *, char **));
^
In file included from test1.cpp:2:
/usr/gcc/4.7/include/c++/4.7.3/cstdlib:108:11: error: target of using 
declaration conflicts with declaration already in scope
using ::atof;
^
/usr/include/floatingpoint.h:204:15: note: target of using declaration
extern double atof __P((const char *));
^
/usr/include/iso/stdlib_iso.h:124:15: note: conflicting declaration
extern double atof(const char *);
^
In file included from test1.cpp:2:
/usr/gcc/4.7/include/c++/4.7.3/cstdlib:129:11: error: target of using 
declaration conflicts with declaration already in scope
using ::strtod;
^
/usr/include/floatingpoint.h:205:15: note: target of using declaration
extern double strtod __P((const char *, char **));
^
/usr/include/iso/stdlib_iso.h:157:15: note: conflicting declaration
extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
^
4 errors generated.

As always, I don't know, perhaps I'm doing something wrong but maybe 
something is broken :)

-- 
System Administrator of Southern Federal University Computer Center




More information about the oi-dev mailing list