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.
- Create a Win32 console application under VCProgramIf your bisonSource codeContains the main function to create an empty project;
- 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;
- 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.
- 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.
- Then run the command line. Everything is OK.