[cfe-dev] clang finds errors in its own header files
don hinton via cfe-dev
cfe-dev at lists.llvm.org
Fri Dec 23 10:33:54 PST 2016
Hi Paul:
Why are you explicitly including .../c++/4.2.1?
If clang was compiled correctly, it should be able to find it's own c++
headers -- on OSX, that's most likely libc++ headers. Try running:
clang++ -v -c -x c++ - < /dev/null
hth...
don
On Fri, Dec 23, 2016 at 10:12 AM, icloud via cfe-dev <cfe-dev at lists.llvm.org
> wrote:
> I am writing a parser for c++.
>
> I am developing on a Mac. OS X Sierra 10.12.1
>
> I am frustrated by the fact that I cannot compile even the simplest c++
> code because clang 3.9 finds errors in the clang headers themselves! for
> example:
>
> #include "clang/AST/ASTContext.h"
> #include "clang/AST/ASTConsumer.h"
> #include "clang/AST/RecursiveASTVisitor.h"
> #include "clang/Frontend/ASTConsumers.h"
> #include "clang/Frontend/FrontendActions.h"
> #include "clang/Frontend/CompilerInstance.h"
> #include "clang/Tooling/CommonOptionsParser.h"
> #include "clang/Tooling/Tooling.h"
> #include "clang/Rewrite/Core/Rewriter.h"
> #include "llvm/Support/raw_ostream.h"
> #include <string>
> #include <memory>
>
>
> int main( void )
> {
> return 0;
> }
>
>
> ---
>
> My output from running make is:
>
> "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f
> nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
> "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f
> nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/parser
> mkdir -p build/Debug/CLang-MacOSX
> rm -f "build/Debug/CLang-MacOSX/main.o.d"
> clang++ -c -g -I/usr/local/include -I/usr/include/c++/4.2.1
> -I/usr/include/c++/4.2.1 -std=c++14 -MMD -MP -MF "build/Debug/CLang-MacOSX/main.o.d"
> -o build/Debug/CLang-MacOSX/main.o main.cpp
> In file included from main.cpp:2:
> In file included from /usr/local/include/clang/AST/AST.h:18:
> In file included from /usr/local/include/clang/AST/ASTContext.h:18:
> In file included from /usr/local/include/clang/AST/ASTTypeTraits.h:20:
> In file included from /usr/local/include/clang/AST/Decl.h:17:
> In file included from /usr/local/include/clang/AST/APValue.h:17:
> In file included from /usr/local/include/clang/Basic/LLVM.h:22:
> In file included from /usr/local/include/llvm/Support/Casting.h:19:
> In file included from /usr/local/include/llvm/Support/type_traits.h:18:
> In file included from /usr/include/c++/4.2.1/utility:67:
> /usr/include/c++/4.2.1/bits/stl_pair.h:96:22: error: unknown type name
> 'pair'
> operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:96:26: error: expected ')'
> operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:96:15: note: to match this '('
> operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:97:14: error: use of undeclared
> identifier '__x'
> { return __x.first == __y.first && __x.second == __y.second; }
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:97:27: error: use of undeclared
> identifier '__y'
> { return __x.first == __y.first && __x.second == __y.second; }
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:97:40: error: use of undeclared
> identifier '__x'
> { return __x.first == __y.first && __x.second == __y.second; }
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:97:54: error: use of undeclared
> identifier '__y'
> { return __x.first == __y.first && __x.second == __y.second; }
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:102:21: error: unknown type name
> 'pair'
> operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:102:25: error: expected ')'
> operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:102:14: note: to match this '('
> operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> ^
> /usr/include/c++/4.2.1/bits/stl_pair.h:103:26: error: use of undeclared
> identifier '__y'; did you mean '__1'?
> { return __x.first < __y.first
> ^
> */usr/local/bin/*../include/c++/v1/type_traits:393:1: note: '__1'
> declared here
> _LIBCPP_BEGIN_NAMESPACE_STD
> ^
> */usr/local/bin/*../include/c++/v1/__config:353:69: note: expanded from
> macro '_LIBCPP_BEGIN_NAMESPACE_STD'
> #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace
> _LIBCPP_NAMESPACE {
> ^
> */usr/local/bin/*../include/c++/v1/__config:67:27: note: expanded from
> macro '_LIBCPP_NAMESPACE'
> #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
> ^
> ... and so on ... until:
>
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> 20 errors generated.
> make[2]: *** [build/Debug/CLang-MacOSX/main.o] Error 1
> make[1]: *** [.build-conf] Error 2
> make: *** [.build-impl] Error 2
>
> If I were to take a completely wild stab in the dark I would say clang
> thinks I'm compiling C code, not C++.
>
> maybe some missing extern "C"{ statements?
>
> Help will be greatly appreciated.
>
> --
>
> Paul
>
>
> --
>
> Paul
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161223/26e038c4/attachment.html>
More information about the cfe-dev
mailing list