1

In clang there is this file. I'm trying to reference one of the overloaded methods:

00909   std::string getAsString(const PrintingPolicy &Policy) const;

I tried:

std::__cxx11::basic_string<char> (&p2)(const clang::PrintingPolicy&) = &clang::QualType::getAsString;

and got:

REPL:1:73: error: address of overloaded function 'getAsString' does not match required type 'std::__cxx11::basic_string<char> (const clang::PrintingPolicy &)'
std::__cxx11::basic_string<char> (&p2)(const clang::PrintingPolicy&) = &clang::QualType::getAsString
/home/a/julia/usr/bin/../include/clang/AST/Type.h:905:15: note: candidate function has different qualifiers **(expected none but found const)**
  std::string getAsString(const PrintingPolicy &Policy) const;

I also tried:

std::__cxx11::basic_string<char> (&p1)(clang::PrintingPolicy&) = &clang::QualType::getAsString;

and got:

candidate function has type mismatch at 1st parameter **(expected 'clang::PrintingPolicy &' but has 'const clang::PrintingPolicy &')**

Am I doing something wrong or is the compiler broken?

honk
  • 9,137
  • 11
  • 75
  • 83
  • My money is definitely on you being wrong. (Hint: non-static member functions are very different from free functions.) – T.C. Jan 27 '16 at 20:33
  • I just need the address of the method, and it seems like the compiler is ok with it until it shows the const? –  Jan 27 '16 at 20:43
  • Btw I'm doing this because of an open bug in clang similar to these poor chaps https://www.bountysource.com/issues/29193004-link-errors-on-debian-sid but their solution did not work for me –  Jan 27 '16 at 20:50
  • This is also related http://stackoverflow.com/questions/33368237/undefined-reference-in-clang-when-linking-to-a-library-compiled-with-gcc5 :/ –  Jan 27 '16 at 23:24

0 Answers0