Compiling MFC

Boaz Harrosh boaz at hishome.net
Sun Oct 5 03:54:26 CDT 2003


I have compiled MFC from MSVC6 (not 7) do you want a patch file?

I have a good solution for the __try __except if you are compiling C++ 
code. (using the C++ try catch). I'm afraid I do not have a good 
solution for C compilations. (Yet) But for MFC it is good.

<C++ code>
#define __try try
#define CONCAT(s1,s2) _CONCAT_(s1,s2)
#define _CONCAT_(s1,s2) s1##s2
#define __except( foofoo ) \
  catch(...){ \
  int d = foofoo ; \
  switch(d){ \
  case 0: \
    throw ; \
  case -1: \
  case 1 : \
  goto CONCAT(label,__LINE__) ; } } CONCAT(label,__LINE__) :

<C++ code/>
the double CONCAT macros are so __LINE__ gets expanded. It would not 
near a ## operator. the order is important. Try for yourself it took me 
a while. The purpose is that two __try __except statement can coexist in 
the same function.
Also maybe at the "case 0:" we should throw a special type so we can 
better handle nested statements. But I have not yet investigated the 
exact behavior of the MSVC in that respect. So this should do for now.

Free Life
Boaz

Gregory M. Turner wrote:

>On Friday 03 October 2003 07:04 am, Adam Connell wrote:
>  
>
>>I am yet another programmer trying to compile the MFC with winelib.
>>I believe that I have the project configured correctly. I am currently
>>working on getting it to compile. I am having trouble with Microsoft's
>>extensions to C++ specifically:
>>throw(...)
>>__try
>>__except
>>
>>Is there any kind of work around for these things?
>>
>>MFC v7.0
>>g++ v3.2.2
>>wine-cvs
>>    
>>
>
>You have uncovered a very squirmy can of worms, I'm afraid.
>
>You have several options, all of them sub-optimal:
>
>1) Use a patched gcc, see http://reactos.wox.org/index.php?page=gccseh
>2) Convert the __try blocks into __TRY blocks as supported by wine, see 
>include/wine/exception.h.  This will require pretty extensive rewriting of 
>the affected code blocks.
>3) Just use dummy macros, along the lines of those in include/rpc.h.  This 
>approach will /not/ do any real exception handling, but will get you 
>compiling quickly... no guarantees your compiled code will work, however.
>4) See my old attempts to create macros that approximate this using 
>gcc-specific nested functions capabilities, for example, see 
>http://www.winehq.com/hypermail/wine-devel/2003/05/0394.html
>There are probably a dozen or more such attempts floating around, none of them 
>quite do the right thing of course :(
>
>Sorry, this business is messy and so far no really satisfactory solution has 
>been created for a number of reasons.  Good luck!
>
>  
>




More information about the wine-devel mailing list