开发者

Compile error for the Hello pass example of llvm

I was trying the Hello pass example in the "Writing an LLVM Pass" webpage. I followed the instructions to compile (with gcc-4.2) the Hello.cpp, but I got the compile errors:

Hello.cpp:20: error: expected identifier before string constant

Hello.cpp:20: error: expected ',' or '...' before string constant

Hello.cpp:20: error: expected constructor, destructor, or type conversion before ';' token

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

#include "llvm/Pass.h"  
#include "llvm/Function.h"  
#in开发者_如何学JAVAclude "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);  
}

Could any one help me with this? Thank you very much!

Best,

Daniel


This is the demo code. This should work fine except for line 11, which should be:

    Hello() : FunctionPass(ID) {}

I am using llvm v2.8, and with that small change everything seems to be working well. But I renamed the program to something else as the Hello pass was already existing.

Follow the instructions in llvm v2.8, Writing an llvm pass

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜