   problems pasting code from VC6 to VC2005
  I recently made the switchover from VC++6 to VC++2005 and found out how to link to the Windows SDK, link to the DirectX SDK, and create an empty Win32 application project.  I then pasted my old code from VC++6 into my new project and tried to compiler it.  However, I got tons of errors (keep in mind that this code would execute perfectly in VC++6).For one thing, I can't make statements like this anymore:MSG msg;ZeroMemory(&msg,sizeof(msg));The compiler gives me the following when I try and perform the above:": error C4430: missing type specifier - int assumed. Note: C++ does not support default-int: error C2365: 'memset' : redefinition; previous definition was 'function'   c:\program files\microsoft visual studio 8\vc\include\string.h(57) : see declaration of 'memset'"And then there's another strange problem which keeps me from using const strings anywhere in my code.  For example, the following will fail:WNDCLASSEX wndclasswndclass.lpszClassName="windows";giving me the output:": error C2440: '=' : cannot convert from 'const char [6]' to 'LPCWSTR'   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"There are several other strange phenomena that I could mention:VC++2005 won't let me call functions like UnregisterClass.  For example, my code could contain the line below:UnregisterClass("wnd_class", hInst);and the compiler would call errors, saying that:": error C2365: 'UnregisterClassW' : redefinition; previous definition was 'function': see declaration of 'UnregisterClassW'"Perhaps the strangest thing of all is that I cannot create a simple while() loop like such:while(1){  //do whatever}The compiler gives me errors like:": error C2059: syntax error : 'while': error C2447: '{' : missing function header (old-style formal list?)"So I am in a bit of a bad situation here, obviously.  Is there some option I need to enable for my code to work properly, or do I just have to change my code?  If so, are there any other dramatic changes to C++ that I need to look out for?Thanks very much for your help!   
  Some of your troubles can be fixed by going to your project properties, under general, change the Character Set setting to "Use Multi-Byte Character Set".   ;  For one problem i can help you. VC 2005 always defines the Preprocessor macro "UNICODE" for each project that you create with the application wizards. Just remove that from yor Project Options / Extended Command Line settings ( or altnerativly disable Unicode support for your project in the settings ) and at least the const string problem should vanish.Background: If UNICODE is defined windows.h includes the files for its structures with unicode data types. WndClass.lpszCLassName becomes a unicode string as such you can't assign a normal const char * to it ( which is what a literal string constant is translated to ). Either follow the above advice or you can also prefix your string constants by  L"MyWindClass" which will make them unicode constants.   ;Quote:Original post by synth_catAnd then there's another strange problem which keeps me from using const strings anywhere in my code.  For example, the following will fail:*** Source Snippet Removed ***giving me the output:": error C2440: '=' : cannot convert from 'const char [6]' to 'LPCWSTR'   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"By default, unicode is enabled in VC 2005. So I think the problem is that wndclass.lpszClassName expects a unicode string. You can turn off unicode support by setting Project Properties->General->Character Set: Not Set. I think you can also make string literals unicode by prefixing them with an L:WNDCLASSEX wndclasswndclass.lpszClassName=L"windows";;  Visual Studio 2005 is a C++ standards-compliant compiler, whereas Visual C++ 6.0 lets you do Bad Things (TM) that the standard does not allow for. First of, as others have mentioned, if you deactivate Unicode and use Multi-Byte instead, you will knock off a huge amount of errors.Second, I can see by your first error message that you are using string.h. This file is deprecated, which means it is not a good idea to use it. Instead, include string support like this:#include <string>  // without the .h!Then you can either:A) Declare this at the top of your file: using namespace std;ORB) Prefix every occurence of string with std::This is how all modern compilers should work, because it is the way the C++ standards commitee has decided they should be. After those two things are fixed, come back and tell us if any more errors remain.PS. The while problem probably comes from the fact that your ZeroMemory call is actually a macro that is messing up, which will probably mess up a lot of the code below it.   ;  There should be some sort of VC2005 "gotcha!" page.Topics including:1) Unicode2) Deprecated C funcions3) Deploying and Manifest Files4) Platform SDK5) C runtime conflicts6) How to turn off bounds-checking for vectors   ;Quote:Original post by ussnewjersey4Visual Studio 2005 is a C++ standards-compliant compiler, whereas Visual C++ 6.0 lets you do Bad Things (TM) that the standard does not allow for. First of, as others have mentioned, if you deactivate Unicode and use Multi-Byte instead, you will knock off a huge amount of errors.Second, I can see by your first error message that you are using string.h. This file is deprecated, which means it is not a good idea to use it. Instead, include string support like this:#include <string>  // without the .h!Then you can either:A) Declare this at the top of your file: using namespace std;ORB) Prefix every occurence of string with std::This is how all modern compilers should work, because it is the way the C++ standards commitee has decided they should be. After those two things are fixed, come back and tell us if any more errors remain.PS. The while problem probably comes from the fact that your ZeroMemory call is actually a macro that is messing up, which will probably mess up a lot of the code below it.Uh, 'string.h' holds the C-style string manipulation functions, not "the old string class" (there wasn't one AFAIK). If you still want the C-style string manipulation functions (strcmp, strlen etc.), you can get them from including <cstring>. This will still dump those free functions into the std:: namespace in the same way. However, you would do yourself a huge favour to ask yourself why you're torturing yourself like that, and switch over to using std::string objects instead.Oh, and don't use ZeroMemory or other such things to blank out your arrays. Use std::fill(). It will respect constructors where necessary, and still optimize down to memset() where possible.   ;  I'll tell you all what I have done so far.First, I switched to "Multi Byte Set" which immediately solved all the string errors.  However, I went on and changed <string.h> to <string> and added "using namespace std"VC++2005 had a problem with that particular line, saying:": error C2871: 'std' : a namespace with this name does not exist"However, I still have not been able to solve any of the other problems at all.And I was curious about your advice about disabling the UNICODE setting...Quote:Just remove that from yor Project Options / Extended Command Line settings ( or altnerativly disable Unicode support for your project in the settings )Sorry, but I can't figure out how to find either of these options.  What are the exact paths?Quote:There should be some sort of VC2005 "gotcha!" page.No kidding!  If there were such a page, I would be all over it.  I guess the problem is that there are not a whole lot of people making the switch from VC++6 to VC++2005...Any leads on the other problems?  Am I supposed to use memset instead of ZeroMemory()?  (Just a thought)   ;Quote:Original post by ZahlmanUh, 'string.h' holds the C-style string manipulation functions, not "the old string class" (there wasn't one AFAIK).There was. It's notably the only header from the pre-standard C++ library that had no transition path. For example, the old style iostreams could be placed in iostream.h when the standard versions were transitioned in iostream.   ;  OK, I replaced the code with a shorter, more concise version which should just create a window.#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#include <string>using namespace std;LPDIRECT3D9 d3d=0;LPDIRECT3DDEVICE9 d3ddev=0;bool quit_game=0;bool dead_window=0;LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){switch(msg){case WM_CLOSE:DestroyWindow(hWnd);return 0;case WM_DESTROY:dead_window=1;PostQuitMessage(0);return 0;case WM_KEYUP:if(wParam==VK_ESCAPE){PostQuitMessage(0);}return 0;}return DefWindowProc(hWnd, msg, wParam, lParam);}INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){WNDCLASSEX wc;wc.cbSize=sizeof(WNDCLASSEX);wc.hIcon=NULL;wc.cbClsExtra=0;wc.cbWndExtra=0;wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);wc.hCursor=LoadCursor(0, IDC_ARROW);wc.hIcon=LoadIcon(0, IDI_APPLICATION);wc.hInstance=hInst;wc.lpfnWndProc=WinProc;wc.lpszClassName="synth";wc.lpszMenuName=0;wc.style=CS_HREDRAW | CS_VREDRAW;RegisterClassEx(&wc);HWND hwnd=CreateWindowEx(0,"synth", "the_synth", WS_VISIBLE | WS_OVERLAPPEDWINDOW, 100, 100,800, 600, 0, 0, hInst, 0);   if(!hwnd){MessageBox(0,"big problem","prob",MB_OK);}MSG msg;ZeroMemory(&msg, sizeof(msg));while(msg.message!=WM_QUIT){if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)){TranslateMessage(&msg);DispatchMessage(&msg);}else{if(quit_game){PostQuitMessage(0);break;}}}return 0;}When I compiled this, there were no warnings and no errors whatsover.When I first tried to run this, I got the "big problem" Message Box, which indicated that CreateWindowEx had somehow failed.  But the real problem is that after that, I was unable to build the .exe again.  I keep getting this build error:"LINK : fatal error LNK1168: cannot open C:\Documents and Settings\whoever\My Documents\Visual Studio 2005\Projects\synth\Debug\synth.exe for writing" What does this mean, and how do I fix this so I can build again?  Does this have something to do with the fact that I was selecting "Build <proj_name>" instead of "Build Solution?"Please help!   