[cfe-dev] one of the example program doesn't compiling
Nikola Smiljanic
popizdeh at gmail.com
Wed Aug 13 17:31:23 PDT 2014
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 http://clang.llvm.org/docs/index.html
On Thu, Aug 14, 2014 at 8:38 AM, Krishanthan Krishnamoorthy <
krishan22 at hotmail.com> wrote:
> 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 type*
> *PPContext.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
>
>
>
> _______________________________________________
> 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/581f269e/attachment.html>
More information about the cfe-dev
mailing list