我写了个flex文件,然后用flex生成了一个lex.yy.c
我将这个文件加入到一个项目中,然后用#include "lex.yy.c" 将其inlcude到view类中,但是编译的时候显示如下错误,还有几个警告:
Compiling...
dView.cpp
f:\microsoft visual studio\myprojects\d\lex.yy.c(25) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
Generating Code...
Compiling...
lex.yy.c
f:\microsoft visual studio\myprojects\d\lex.yy.c(55) : warning C4005: 'yyconst' : macro redefinition
        f:\microsoft visual studio\myprojects\d\lex.yy.c(53) : see previous definition of 'yyconst'
f:\microsoft visual studio\myprojects\d\lex.yy.c(62) : warning C4005: 'YY_PROTO' : macro redefinition
        f:\microsoft visual studio\myprojects\d\lex.yy.c(60) : see previous definition of 'YY_PROTO'
f:\microsoft visual studio\myprojects\d\lex.yy.c(1455) : warning C4005: 'yyless' : macro redefinition
        f:\microsoft visual studio\myprojects\d\lex.yy.c(132) : see previous definition of 'yyless'
f:\microsoft visual studio\myprojects\d\lex.yy.c(1533) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Generating Code...
Error executing cl.exe.d.exe - 2 error(s), 3 warning(s)请问怎么解决?那个'unistd.h'去哪里找啊??还有一个问题就是,如果我调用yylex()来扫描文本的话,yylex怎么确定从哪个文本读入呢???
谢谢 

解决方案 »

  1.   

    偶的blog上有blog.csdn.net/chenbuaa
      

  2.   

    你可以拷贝 mingw 上面的 unistd.h 来用。
      

  3.   

    找到了,原来是GNU C++的东西那第二个问题的答案是否就是chenbuaa(萧儿) 的bolg里面的这一段???
    3,数据交换的问题。lex,yacc默认的输入是键盘。因此还要为lex创建一个新的buffer。这里可以建立新的文件作为buffer,也可以用字符串yy_switch_to_buffer(yy_scan_string(m_stredit.GetBuffer(m_stredit.GetLength())));结果的输出可以用一个全局的字符串。还有,第二个错误
    f:\microsoft visual studio\myprojects\d\lex.yy.c(1533) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    是怎么回事啊?
    不可能文件没结尾啊谢谢