<div dir="ltr"><div>Updated versions of this tutorial can be found at:<br><a href="https://github.com/loarabia/Clang-tutorial">https://github.com/loarabia/Clang-tutorial</a><br><br></div>Robert<br><div><div><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
Hi all,<br>
I tried this tutorial (<a href="http://amnoid.de/tmp/clangtut/tut.html" target="_blank">http://amnoid.de/tmp/clangtut/tut.html</a>) and compile the code, but I am getting some errors.<br>
PPContext.h.-----------------<br>
#ifndef PP_CONTEXT#define PP_CONTEXT<br>
#include <string.h><br>
using namespace std;<br>
#include "clang/Frontend/CompilerInstance.h"<br>
#include <llvm/Config/config.h><br>
#include <clang/Basic/Diagnostic.h>#include <clang/Basic/TargetInfo.h>#include <clang/Basic/SourceManager.h>#include <clang/Basic/FileManager.h><br>
#include <clang/Lex/HeaderSearch.h>#include <clang/Lex/Preprocessor.h><br>
#include <clang/Frontend/TextDiagnosticPrinter.h><br>
using namespace clang;<br>
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);  }<br>

  ~PPContext()  {    delete diagClient;    delete target;  }<br>
  clang::DiagnosticClient* diagClient;  clang::Diagnostic diags;  clang::LangOptions opts;  clang::TargetInfo* target;  clang::SourceManager sm;  clang::FileManager fm;  clang::HeaderSearch headers;  clang::Preprocessor pp;};<br>

#endif<br>
tut01_pp.cpp------------------<br>
#include "PPContext.h"<br>
int main(){  //PPContext context;}<br>
<br>
Here I tried to compile the code :<br>
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<br>

But I am getting following error message :<br>
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<br>

Could you please help me with this error.<br>
Thank-You<br>
Krish<br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20140813/6a34b149/attachment-0001.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20140813/6a34b149/attachment-0001.html</a>><br>

<br></blockquote></div></div></div></div></div>