How do I use SW with VS 2010?
I have placed a zipped SmartWin++ version which supports VS2010 on Sourceforge.
The projects have all been updated to Visual Studio 2010 format which is not backwards compatible to VS2008.
Things which are different:
1) VS2010 no longer lets you specify Tools | Options | VC++ Directories. The work around was to create a smartwinprop.props file and make every project include that .props file. So you now must adapt that file to your directory structure.
2) When using VS2010 in debug mode, the old code would crash. (VS2010 release worked though) After tracking it down, MIcrosoft explained:
My name is Lawrence Joel and I am a Software Developer for Microsoft’s VisualC++ team (specifically work on compiler code generation). I was assigned to investigate the access violation (AV) you were experiencing using our compiler for testing your application in debug mode.
Near the top of file include\SmartWin\Smartwin.h there is
// We also need to tell the compiler that it needs to link pointer to members as
// virtual multiple inheritance pointers. We generally want as little as possible
// of Project Settings therefore we set this directly in the code instead of
// forcing the library user to set lots of different settings before managing to
// compile his project.
#pragma pointers_to_members( full_generality, virtual_inheritance )
The pragma will affect how pointers_to_members (PTM) types are implemented. By default the compiler would try to figure out the best way to represent the PTM, with the above pragma settings, any PTM that follows will have the general representation. Crt headers contain some PTM type functions, in our case ostream file has a few instances of this. One source file (stream_err.cpp) includes Smartwin.h which later also includes CRT headers like ostream. The code generated for stream_err will have PTM implemented in the general representation. Another source file (application.cpp) does not include the pragma but has similar CRT headers. The code generated for application.cpp will have PTM implemented based on the compiler decisions (if compiler can find enough info on PTM then it will choose the best case, else choose general case). The linker will take the obj files and will choose one of the PTM implementations (since their names and signature are the same). The AV occurs because a routine will call the PTM routine assuming to have a return value represented in one way but it is represented in another way.
This issue can be fixed in your source code in different ways. If you really need the pragma then I suggest either making the pragma consistent to all source code or to limit it to only places to where it applies. One question that came up during investigation is if you really need this pragma? I believe having __inheritance keywords to the classes can be a better way of enforcing the class to be treated as virtual_inheritance (http://msdn.microsoft.com/en-us/library/ck561bfk(VS.80).aspx) .
The solution adopted was to require /vmg for all SmartWin projects, and removed the #pragma.
Since "smartwinprop.props" is now required for SmartWin projects on VS2010, /vmg was placed in that file.
3) There were some incremental improvements along the way such as Printing support.
Thanks, will give it a try.
sorry by my late message, uptil now i discover this sw.
but then, using vs2010 compiler the project in smartwin only will be for winphone7?
Smartwin can't help you with WinPhone 7 development. See http://msdn.microsoft.com/en-us/library/ff402528(v=VS.92).aspx