我一直在尝试遵循http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/5/上的教程(使用 flex、bison 和 llvm),但是在输入该行时
g++ -o parser parser.cpp tokens.cpp main.cpp
我收到以下错误:
In file included from /usr/local/include/llvm/Support/PointerLikeTypeTraits.h:18:0,
from /usr/local/include/llvm/ADT/PointerIntPair.h:17,
from /usr/local/include/llvm/IR/Use.h:28,
from /usr/local/include/llvm/IR/Value.h:17,
from node.h:3,
from parser.y:2:
/usr/local/include/llvm/Support/DataTypes.h:48:3: erreur: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
/usr/local/include/llvm/Support/DataTypes.h:52:3: erreur: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
parser.y: In function ‘void yyerror(const char*)’:
parser.y:6:58: erreur: ‘printf’ was not declared in this scope
In file included from /usr/local/include/llvm/Support/PointerLikeTypeTraits.h:18:0,
from /usr/local/include/llvm/ADT/PointerIntPair.h:17,
from /usr/local/include/llvm/IR/Use.h:28,
from /usr/local/include/llvm/IR/Value.h:17,
from node.h:3,
from tokens.l:3:
/usr/local/include/llvm/Support/DataTypes.h:48:3: erreur: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
/usr/local/include/llvm/Support/DataTypes.h:52:3: erreur: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
In file included from /usr/local/include/llvm/Support/PointerLikeTypeTraits.h:18:0,
from /usr/local/include/llvm/ADT/PointerIntPair.h:17,
from /usr/local/include/llvm/IR/Use.h:28,
from /usr/local/include/llvm/IR/Value.h:17,
from node.h:3,
from main.cpp:2:
/usr/local/include/llvm/Support/DataTypes.h:48:3: erreur: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
/usr/local/include/llvm/Support/DataTypes.h:52:3: erreur: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
我在互联网上看到过很多这样的帖子,大多数答案都包括在命令行上定义这些常量或使用 gcc Makefile。
我不明白该怎么做,有人可以帮我吗?