-
Upgrading to 2005
Hello, it's me again! A few days I upgraded from Visual C++ 6.0 to Visual 2005 or 8.0, and did some tests, and came with the an error with a code that my old compiler would normally compile with without any errors, I made it simplistic so it only focuses on the problem:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SetConsoleTitle("This is the Title!");
system("PAUSE");
return 0;
}
and these are the errors that come up:
Code:
------ Build started: Project: Title, Configuration: Debug Win32 ------
Compiling...
Code.cpp
c:\documents and settings\george\desktop\c++\title\title\code.cpp(8) : error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [19]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://c:\Documents and Settings\George\Desktop\C++\Title\Title\Debug\BuildLog.htm"
Title - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please help, and thanks in advance!
Can anyone help me? Why is it doing this, as it became even more strict?
-
Sounds like you're compiling with unicode enabled. This should work:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SetConsoleTitle(TEXT("This is the Title!"));
system("PAUSE");
return 0;
}
Alternatively, you could disable unicode
-
Thanks, yet what is a unicode anyway, how can you disable it?
-
A couple links:
http://msdn.microsoft.com/library/de...icode_9i79.asp
http://cprogramming.com/tutorial/unicode.html
As for disabling it, I'm not entirely sure for 2005, but I might guess UNICODE appears under preprocessor definitions in your project options, in which case you could just remove it. Or you could put #undef UNICODE before any includes
-
-
> yet what is a unicode anyway, how can you disable it?
Or get used to it - it isn't going to go away, and more and more stuff will use it in preference to ASCII (or whatever).