January 12, 2012

inopportuno inopportuno
Lab Rat
15 posts

QLALR - QParser example crashes at startup on Visual Studio 2008

 

Unfortunately I have to parse a language (JScript). I started to study how to use Flex knowing that Qt is providing a useful tool called QLALR in order to generate parser.
In \util\qlalr\examples\qparser I found a very interesting example integrating a flex generated scanner and qlalr generated parser. Also, from what I understood (but it couldn’t be true…) the example introduces a useful QParser interface to avoid to rewrite parse function. In order to compile it I had to download a unistd.h for windows from http://sourceforge.net/projects/gnuwin32/files/flex/2.5.4a-1/flex-2.5.4a-1-lib.zip/download. It is in the directory include. In any case is nothing more than:

  1. /*
  2.  
  3. This file is part of the Mingw32 package.
  4. *
  5. unistd.h maps (roughly) to io.h
  6. */
  7. #ifndef _STRICT_ANSI_
  8.  
  9. #include <io.h>
  10. #include <process.h>
  11.  
  12. #endif

Using this file I was able to compile the qparser example but when I run it I get a crash before entering in main function with error message: The program ‘3736 qparser.exe: Native’ has exited with code 2 (0×2).

I’m getting also the following warning messages:

  1. 1>lex.calc.c(903) : warning C4003: not enough actual parameters for macro 'calcwrap'
  2. 1>lex.calc.c(1056) : warning C4018: '<' : signed/unsigned mismatch
  3. 1>lex.calc.c(1238) : warning C4003: not enough actual parameters for macro 'calcwrap'
  4. 1>lex.calc.c(1402) : warning C4996: 'isatty': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _isatty. See online help for details.
  5. 1> c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\io.h(312) : see declaration of 'isatty'
  6. 1>lex.calc.c(1402) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details.
  7. 1> c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(722) : see declaration of 'fileno'
  8. 1>Linking...
  9. 1>LINK : debug
  10. qparser.exe not found or not built by the last incremental link; performing full link

I’m using Visual Studio 2008 on Windows 7 and Qt 4.8.0 compiled from the same package where I got QLALR.

Some suggestions?
Thanks

Guido Ranzuglia

3 replies

January 12, 2012

Volker Volker
Ant Farmer
5331 posts

You should not mix headers (unistd.h) from MinGW with Visual Studio. I don’t know where the get a decent version for MSVS, unfortunately.

January 13, 2012

inopportuno inopportuno
Lab Rat
15 posts

Thanks for the suggestion!

January 13, 2012

inopportuno inopportuno
Lab Rat
15 posts

Ok I resolved the thing by myself.
The problem is that the provided .pro has not included the win32-msvc2008:CONFIG += console directive.
I suggest you, also, to add an %option nounistd at the beginning of the calc.l and an #include<io.h> in order to use the atty function provided in the default include directory.

 
  ‹‹ QLineEdit on OSX and the initial cursor position problem      Rotations with QQuaternion and QSlider ››

You must log in to post a reply. Not a member yet? Register here!