Hello all,

I am learning using Flex with MFC application created with the
appwizard(exe).

I found a step-by-step process on how to integrate Flex with MFC, but
still I could not get it working. In this process, it is told to add
the Flex function in _tmain of MFC. But as far as I know there is no
main function (or we cannot modify) in the MFC appwizard based
project.

Here are the steps I followed.
-------------------------------------------------------------------------------
1. Create a new application that supports MFC

2. Add the file, cs.l, to the project work space

3. Right click cs.l file, select "settings..." and select the Custom
Build
tab
4. Enter "?\flex.exe" cs.l in the commands section (where ? indicates
location of flex executable)
5. Enter "lex.yy.c" in the outputs section
6. Right click the cs.l file and select compile (this will generate
lex.yy.c)
7. Add lex.yy.c to the project
8. Right click the lex.yy.c file, and select settings, then select
"Precompiled Headers" in the combo box and select "Not using
precompiled
headers"
9. Create a new file, called, for example lex.yy.h, add it to the
project
and insert the following:

extern "C" int MyLexFunction(int, char *);

10. select the StdAfx.h file and #include the file created in step 9.
11. Add the following code to the MFC main function:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
....
nRetCode = MyLexFunction(argc, (char *)(argv));
....
}

12. Compiling the entire project should work and the lex function can
be
called from the MFC project.

--------------------------------------------------------------------------------

Can some on please please help me on how to integrate the Flex
generated C code with the MFC appwizard(exe)project.

I really appreciate your help.

Thank you
-Venkat