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

Krishanthan Krishnamoorthy krishan22 at hotmail.com
Wed Aug 13 15:38:16 PDT 2014

Hi all,
I tried this tutorial (http://amnoid.de/tmp/clangtut/tut.html) and compile the code, but I am getting some errors.
#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;};
#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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140813/6a34b149/attachment.html>

More information about the cfe-dev mailing list