PermaLink VS.Net 2003 to VS.Net 2005 C++ Code Conversion Tips03/02/2007 04:15 PM
You'd think there'd be a "backwards compatibility mode" when VS.Net 2005 imports VS.Net 2003 C++ projects, but noooo :-P
At any rate, here are some tips on what you'll hit and how to fix them...

When you have a for loop and declare the index variable in it, it used to be instantiated for the entire function so you can use it in other for loops:
  for (int i = 0; ...)
Now, it's instantiated only within the loop (more like C#), so if you want to declare it only once for your function, you have to pull it out of the loop declaration:
  int i;
  for (i = 0; ...)

If you have ON_WM_NCHITTEST() in any of your Windows subclassing code, you'll get this cryptic error:
  cannot convert from 'UINT (__thiscall CMyControl::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)' Cast from base to derived requires dynamic_cast or static_cast
and to fix it, you have to change your head file and function declaration for
  afx_msg UINT OnNcHitTest(CPoint point);
to:
  afx_msg LRESULT OnNcHitTest(CPoint point);

If you reference a class' member functions by assigning them to pointer
  pMyFunc = MyMemberFunction
you have to preface the function name with the class name and a reference symbol:
 pMyFunct = &MyClass::MyMemberFunction

You can no longer let the compiler assume untyped variables are int. So these won't work:
  const myconst = 10;
  register i;
Instead, you have to do this:
  const int myconst = 10;
  register int i;

I think I like C# and Java much better now... ;-)

Comments :v
No comments.

Start Pages
RSS News Feed RSS Comments Feed CoComment Integrated
The BlogRoll
Calendar
November 2024
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Search
Contact Me
About Ken
Full-stack developer (consultant) working with .Net, Java, Android, Javascript (jQuery, Meteor.js, AngularJS), Lotus Domino