Compile flex and bison code in Visual Studio

Source: Internet
Author: User

In cygwin, I wrote a Assembler and used flex and bison for lexical and syntax analysis. It can be run in cygwin, but the assembler has to encapsulate it as part of the entire function to provide external interfaces. Next, let's talk about the porting process and problems.

  1. Create a Win32 console application under VCProgramIf your bisonSource codeContains the main function to create an empty project;
  2. In Windows, the flex and bison source code (ER er. l and assembler. Y) should be re-compiled to generate the file erer_tab.h, assembler_tab.c, Lex. yy. C. The file name here is different from that in cygwin. The file names generated in cygwin are cycler. Tab. C, cycler. Tab. H, Lex. yy. C, and Cycler are my own names;
  3. Add the assembler_tab.h, assembler_tab.c, and Lex. yy. c files to the Project for compilation. An error message is displayed, indicating that the "Eh. H" file is only applicable to C ++. By default, the C compiler is used for files suffixed with. C by VC,CodeWhen C ++ is used, an error is reported. The method for forcibly setting the compiler type for half a day is not found. simply use the simplest method to change the. c suffix to. cpp.
  4. Re-compile, error, prompt cannot open include file: 'unistd. H 'file. Check whether the file is in Linux, which is equivalent to stdlib in windows. h, so it should be useless in windows, so comment it out and compile it.
  5. Then run the command line. Everything is OK.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.