Error using Clang tool to parse standard C ++ header file

I use the clang tool to parse a standard header file located in / usr / lib / gcc / x 86_64-linux-gnu / 4.7 / string. But I get the following error.

In file included from ~/PrototypeWork/user/header.hpp:3:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/string:41:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/char_traits.h:41:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/postypes.h:41:
/usr/include/c++/4.7/tr1/cwchar:42:14: error: no member named 'wcstof' in namespace 'std'
  using std::wcstof;
        ~~~~~^
/usr/include/c++/4.7/tr1/cwchar:45:14: error: no member named 'vfwscanf' in namespace 'std'
  using std::vfwscanf;
    ~~~~~^

The problem was that clang reads the string header as the C header instead of the C ++ header and therefore cannot parse the "use" of the keyword. Therefore, I added additional -TP command-line options that say that treating all source files as C ++, but that didn't help.

After using the -TP command line option, the following warning appears

warning: argument unused during compilation: '-T P'

Can someone help me with this problem?

Clang command line options: http://clang.llvm.org/docs/UsersManual.html#id5

:

    int main() {
    std::vector<std::string> cmdLine = boost::assign::list_of
                        ("-TP")
                        ("-I/usr/include")
                        ("-I/usr/include/c++/4.7/tr1/");
    clang::tooling::FixedCompilationDatabase db(".",cmdLine); 

// Provide clang with the header file that needs to be parsed

// Run the clang tool .
}
+4
1

, ", ", : , #include <cwchar>? clang , gcc, ​​, , .

+2

Source: https://habr.com/ru/post/1548381/


All Articles