<div dir="ltr">That tutorial is from 2008, and I'm sure many things have changed since then. What exactly would you like to use clang for? We have documentation for most common stuff at <a href="http://clang.llvm.org/docs/index.html">http://clang.llvm.org/docs/index.html</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 8:38 AM, Krishanthan Krishnamoorthy <span dir="ltr"><<a href="mailto:krishan22@hotmail.com" target="_blank">krishan22@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr">Hi all,<div><br></div><div>I tried this tutorial (<a href="http://amnoid.de/tmp/clangtut/tut.html" style="font-size:12pt" target="_blank">http://amnoid.de/tmp/clangtut/tut.html</a>) <span style="font-size:12pt">and compile the code, but I am getting some errors.</span></div>
<div><span style="font-size:12pt"><br></span></div><div><span style="font-size:12pt">PPContext.h.</span></div><div><span style="font-size:12pt">-----------------</span></div><div><span style="font-size:12pt"><br></span></div>
<div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#ifndef PP_CONTEXT</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#define PP_CONTEXT</font></i></div><div>
<i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <string.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br>
</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">using namespace std;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div>
<i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include "clang/Frontend/CompilerInstance.h"</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <llvm/Config/config.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div>
<i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Basic/Diagnostic.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Basic/TargetInfo.h></font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Basic/SourceManager.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Basic/FileManager.h></font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Lex/HeaderSearch.h></font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Lex/Preprocessor.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#include <clang/Frontend/TextDiagnosticPrinter.h></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br>
</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">using namespace clang;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">struct PPContext {</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> // Takes ownership of client.</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> PPContext(clang::DiagnosticClient* client = 0,</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> const std::string& triple = LLVM_HOSTTRIPLE)</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> : diagClient(client == 0?new clang::TextDiagnosticPrinter:client),</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> diags(diagClient),</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> target(clang::TargetInfo::CreateTargetInfo(triple)),</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> headers(fm),</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> pp(diags, opts, *target, sm, headers)</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> {</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> // Configure warnings to be similar to what command-line `clang` outputs</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> // (see tut03).</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> // XXX: move warning initialization to libDriver</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> using namespace clang;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> diags.setDiagnosticMapping(diag::warn_pp_undef_identifier,diag::MAP_IGNORE);</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> }</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> ~PPContext()</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> {</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> delete diagClient;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> delete target;</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> }</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br></font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::DiagnosticClient* diagClient;</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::Diagnostic diags;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::LangOptions opts;</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::TargetInfo* target;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::SourceManager sm;</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::FileManager fm;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::HeaderSearch headers;</font></i></div>
<div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"> clang::Preprocessor pp;</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">};</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec"><br>
</font></i></div><div><i style="background-color:rgb(255,255,255)"><font color="#2672ec">#endif</font></i></div><div><br></div><div>tut01_pp.cpp</div><div>------------------</div><div><br></div><div><div><font color="#2672ec">#include "PPContext.h"</font></div>
<div><font color="#2672ec"><br></font></div><div><font color="#2672ec">int main()</font></div><div><font color="#2672ec">{</font></div><div><font color="#2672ec"> //PPContext context;</font></div><div><font color="#2672ec">}</font></div>
</div><div><br></div><div><br></div><div>Here I tried to compile the code :</div><div><br></div><div><span style="font-size:12pt"><font color="#e1c404">g</font><font color="#ac193d">++ -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</font></span></div>
<div><span style="font-size:12pt"><br></span></div><div>But I am getting following error message :</div><div><br></div><div><div><font color="#008a17"><b>In file included from tut01_pp.cpp:1:0:</b></font></div><div><font color="#008a17"><b>PPContext.h:48:30: error: expected ‘)’ before ‘client’</b></font></div>
<div><font color="#008a17"><b>PPContext.h:69:3: error: ‘DiagnosticClient’ in namespace ‘clang’ does not name a type</b></font></div><div><font color="#008a17"><b>PPContext.h: In destructor ‘PPContext::~PPContext()’:</b></font></div>
<div><font color="#008a17"><b>PPContext.h:65:12: error: ‘diagClient’ was not declared in this scope</b></font></div></div><div><br></div><div>Could you please help me with this error.</div><div><br></div><div>Thank-You</div>
<div><br></div><div>Krish</div><div><br></div><div style="font-size:12pt"><br></div></div> </div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>