GNU flex unistd.h在VC下的编译问题
2010-08-19 21:28
337 查看
问题现象:
原因,flex生成的代码如下:
如果flex命令行调用加上 --nounistd 或者在词法描述文件中加上 %option nounistd,则可能产生如下错误:
解决方法:
1. 包含 <io.h>里面声明了windows版本的isatty函数。
2. 在词法描述文件中加上 %option never-interactive,这个选项向flex表明输入时非交互式的,此时flex不会调用isatty来查询输入设备类型。
...: fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
原因,flex生成的代码如下:
#ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ /* %if-c-only */ #include <unistd.h> /* %endif */ /* %if-c++-only */ /* %endif */ #endif
如果flex命令行调用加上 --nounistd 或者在词法描述文件中加上 %option nounistd,则可能产生如下错误:
...: error C2447: '{' : missing function header (old-style formal list?) ...: warning C4018: '<' : signed/unsigned mismatch ...: error C3861: 'isatty': identifier not found
解决方法:
1. 包含 <io.h>里面声明了windows版本的isatty函数。
2. 在词法描述文件中加上 %option never-interactive,这个选项向flex表明输入时非交互式的,此时flex不会调用isatty来查询输入设备类型。
isatty is used by the lexer to determine if the input stream is a terminal or a pipe/file. The lexer uses this information to change its caching behavior (the lexer reads large chunks of the input when it is not a terminal). If you know that your program will never be used in an interactive kind, you can add %option never-interactive to you lexer. When the program is run with user input, use %option interactive. When both uses are desired, you can either generate an interactive lexer, which gives a performance loss when used in batch mode, or provide your own isatty function.
相关文章推荐
- vc6 和 vc8 同时编译stlport 5.1.4 引起的问题
- vc7/vc8 C语言项目 mysql 编译问题
- gcc编译报错,fatal error: gnu/stubs-soft.h: No such file or directory问题解决!!
- VC++编译JSON源码常遇到的问题。
- Ant命令编译flex时碰到的问题:[mxmlc] java.lang.OutOfMemoryError: Java heap space
- log4cpuls在vc2010上编译的问题
- vc6 在win10上编译x64程序的问题总结
- 最著名的问题-------本机编译好的程序无法在没有装VC的机子上运行
- VC下UDP 编译问题
- VC++ 升级到visual studio 2008 后,调试DirectShow中的Sample编译出错问题解决方案
- 关于编译内核时候出现__gnu_mcount_nc的问题以及解决办法
- 【vc++ 2010问题】使用visual c++/studio 2010编译程序后,出现_CrtIsValidHeapPointer(pUserData)错误
- 一个VC6的工程转换为VS2008的工程后,编译找不到而且不能升级vc90.pdb文件的问题解决方法 2010-9-28 14:00
- VC6 编译选项问题
- flex 编译问题总结一
- VC++头文件中的条件编译问题(转载)
- VC编译库顺序的问题
- VC++编译问题汇总1 单链表的表示和实现,基于c++
- VC下编译和链接常出现的问题汇总
- vc 编译遇到问题