3/07/2009

common Problems with Flex on Windows

The followings are common errors when using Flex to do language processing on Windows platform.

1. isatty()

Problem:
error LNK2019: unresolved external symbol "int __cdecl isatty(int)" referenced in function "void __cdecl yy_init_buffer(struct yy_buffer_state *,struct _iobuf *)"

Solution:
  1.1 define YY_NEVER_INTERACTIVE as 1 or o in your lex syntax file

2. unistd.h

Problem:
fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory


Solution:
  2.1 use flex parameter: --nounistd
  2.2 use flex option: %option nounistd
  2.3 try other version of flex, which will produce "#ifndef _MSC_VER #include #endif" like code
  2.4 create an empty unistd.h file under the include search directory of your compiler

No comments: