#error “必须在#include Support/DataTypes.h 之前#define __STDC_LIMIT_MACROS" [英] #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"

查看:16
本文介绍了#error “必须在#include Support/DataTypes.h 之前#define __STDC_LIMIT_MACROS"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试遵循 http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/5/(使用 flex、bison 和 llvm)但是在输入行时

I have been trying to follow the tutorial at http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/5/ (using flex, bison and llvm) but when typing the line

g++ -o parser parser.cpp tokens.cpp main.cpp

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.

I have seen lots of posts like this on the internet, and most of the answers include defining these constants on the command line or by using gcc Makefile.

我不明白该怎么做,有人可以帮我吗?

I don't understand how to do that, could someone help me out?

推荐答案

将此附加到您的命令行:

Append this to your command line:

-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS

有关 -D 命令行选项的更多信息,请参阅 gcc 关于预处理器选项的文档.

For more information about the -D command line option, refer to gcc's documentation on preprocessor options.

这篇关于#error “必须在#include Support/DataTypes.h 之前#define __STDC_LIMIT_MACROS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆