[cfe-dev] one of the example program doesn't compiling

Krishanthan Krishnamoorthy krishan22 at hotmail.com
Thu Aug 14 08:14:49 PDT 2014


Hi Robert,
Thank-you for the link. I tried to compile that tutorial files, but I am getting following error. 
tutorial1.cpp:55:13: error: reference to type 'const std::shared_ptr<TargetOptions>' could not      bind to an rvalue of type 'clang::TargetOptions *'            &targetOptions);            ^~~~~~~~~~~~~~/home/krish/llvm/tools/clang/include/clang/Basic/TargetInfo.h:99:58: note: passing argument to      parameter 'Opts' here                   const std::shared_ptr<TargetOptions> &Opts);                                                         ^tutorial1.cpp:68:25: error: no matching constructor for initialization of 'clang::Preprocessor'    clang::Preprocessor preprocessor(                        ^/home/krish/llvm/tools/clang/include/clang/Lex/Preprocessor.h:451:3: note: candidate constructor      not viable: no known conversion from 'clang::TargetInfo *' to 'clang::SourceManager &' for      4th argument  Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,  ^/home/krish/llvm/tools/clang/include/clang/Lex/Preprocessor.h:88:7: note: candidate constructor      (the implicit copy constructor) not viable: requires 1 argument, but 7 were providedclass Preprocessor : public RefCountedBase<Preprocessor> {      ^2 errors generated.make: *** [tutorial1.o] Error 1
Actually, this tutorial will help me to achieve my goal, so I really want to test it.
Thanks.
Krish
Date: Wed, 13 Aug 2014 17:54:01 -0700
From: rrankene at gmail.com
To: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] one of the example program doesn't compiling

Updated versions of this tutorial can be found at:
https://github.com/loarabia/Clang-tutorial

Robert






Hi all,

I tried this tutorial (http://amnoid.de/tmp/clangtut/tut.html) and compile the code, but I am getting some errors.

PPContext.h.-----------------

#ifndef PP_CONTEXT#define PP_CONTEXT

#include <string.h>

using namespace std;

#include "clang/Frontend/CompilerInstance.h"

#include <llvm/Config/config.h>

#include <clang/Basic/Diagnostic.h>#include <clang/Basic/TargetInfo.h>#include <clang/Basic/SourceManager.h>#include <clang/Basic/FileManager.h>

#include <clang/Lex/HeaderSearch.h>#include <clang/Lex/Preprocessor.h>

#include <clang/Frontend/TextDiagnosticPrinter.h>

using namespace clang;

struct PPContext {  // Takes ownership of client.  PPContext(clang::DiagnosticClient* client = 0,            const std::string& triple = LLVM_HOSTTRIPLE)    : diagClient(client == 0?new clang::TextDiagnosticPrinter:client),      diags(diagClient),      target(clang::TargetInfo::CreateTargetInfo(triple)),      headers(fm),      pp(diags, opts, *target, sm, headers)  {    // Configure warnings to be similar to what command-line `clang` outputs    // (see tut03).    // XXX: move warning initialization to libDriver    using namespace clang;    diags.setDiagnosticMapping(diag::warn_pp_undef_identifier,diag::MAP_IGNORE);  }


  ~PPContext()  {    delete diagClient;    delete target;  }

  clang::DiagnosticClient* diagClient;  clang::Diagnostic diags;  clang::LangOptions opts;  clang::TargetInfo* target;  clang::SourceManager sm;  clang::FileManager fm;  clang::HeaderSearch headers;  clang::Preprocessor pp;};


#endif

tut01_pp.cpp------------------

#include "PPContext.h"

int main(){  //PPContext context;}



Here I tried to compile the code :

g++ -I/home/krish/llvm/build/include -I/home/krish/llvm/tools/clang/include `/home/krish/llvm/build/Release+Asserts/bin/llvm-config -cxxflags` -fno-rtti -c tut01_pp.cpp -std=gnu++11 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROSD -D__STDC_LIMIT_MACROS


But I am getting following error message :

In file included from tut01_pp.cpp:1:0:PPContext.h:48:30: error: expected ?)? before ?client?PPContext.h:69:3: error: ?DiagnosticClient? in namespace ?clang? does not name a typePPContext.h: In destructor ?PPContext::~PPContext()?:PPContext.h:65:12: error: ?diagClient? was not declared in this scope


Could you please help me with this error.

Thank-You

Krish





-------------- next part --------------

An HTML attachment was scrubbed...

URL: <http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20140813/6a34b149/attachment-0001.html>





_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140814/1e4b5cae/attachment.html>


More information about the cfe-dev mailing list