Compilation error for Hello pass llvm example

I tried the Hello pass example on the "Writing LLVM Pass" web page . I followed the compilation instructions (with gcc-4.2) Hello.cpp, but I got compilation errors:

Hello.cpp: 20: error: expected identifier to string constant Hello.cpp: 20: error: expected identifier
',' or '...' to string constant
Hello.cpp: 20: error: expected constructor, destructor or type conversion before ';' Marker

which is the line INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false);in the program. Program:

#include "llvm/Pass.h"  
#include "llvm/Function.h"  
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {  

 struct Hello : public FunctionPass {  
    static char ID;  
    Hello() : FunctionPass(&ID) {}  

    virtual bool runOnFunction(Function &F) {  
        errs() << "Hello: " << F.getName() << "\n";  
        return false;  
    }  
 };  

 char Hello::ID = 0;  
 INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false);  
}

Can someone help me with this? Thank you very much!

Best
daniel

+3
1

. , 11, :

    Hello() : FunctionPass(ID) {}

llvm v2.8, , , . - , Hello-pass .

llvm v2.8, llvm-

0

Source: https://habr.com/ru/post/1759368/


All Articles