|
Error occuring with DirectX program
» When calling a windows defined structure |
|
02-05-2010, 09:52 AM
Post: #1
|
|||
|
|||
|
Hi,
I've been trying to get a demo program for DirectX to run and I'm getting the following error log when compiling: Code: - cannot convert `const wchar_t[12]' to `const CHAR*' in assignmentCode: - cannot convert `const wchar_t*' to `const CHAR*' for argument `2' to `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'The code defines a structure of type WNDCLASSEX with a variable name called 'wc'. When it hits the following line: Code: wc.lpszClassName = L"WindowClass";It gets mad. I checked out online what the structure WNDCLASSEX has as its defined data members and it seems the variable lpszClassName requires a pointer to a classname which is terminated with a null character - which as I understand can be represented with '/0'. I don't think the null character is an issue though as if you look it is complaining that an array called wchar_t[12] cannot convert to what looks like a pointer to a constant variable of type char - but written in capitals for some reason. Given that there are 11 letters in the name "Windowclass" then it follows that the code must have implemented a null character automatically as the array size is 12 not 11. I also thought an array variable was basically just read as a pointer by code too. So it seems to me that the data member of the structure WNDCLASSEX is being passed a pointer to a null terminated string, yet the program still complains. Can anyone shed any light on this, is this an issue relating to a windows version which is out of date or something? Cheers! |
|||
|
02-06-2010, 01:34 PM
Post: #2
|
|||
|
|||
|
RE: Error occuring with DirectX program
It's \0...
However, when using things like CreateWindowEx, you NEED to use const char*! Literally, you need to make sure your string is a pointer. If you have say, char b[20] = {"Some phrase"}; Then you need to make a pointer to it. const char *pb = &b; and then put it into the createwindowex. Obviously some experimenting would be required. ![]() ☤ ☢ Software Engineer - Director of Inferno ☢ ☤ |
|||
|
02-06-2010, 07:11 PM
Post: #3
|
|||
|
|||
|
RE: Error occuring with DirectX program
Thanks Brian
|
|||
|
02-08-2010, 03:16 AM
Post: #4
|
|||
|
|||
|
RE: Error occuring with DirectX program
I think reading a few tutorials on pointers would help you a lot in this area. Windows API can get confusing with all the pointers.
|
|||
|
02-09-2010, 11:30 PM
(This post was last modified: 02-09-2010 11:32 PM by rubix.)
Post: #5
|
|||
|
|||
RE: Error occuring with DirectX program
(02-06-2010 01:34 PM)Brian Wrote: Guests cannot see links in the messages. Please register to forum by clicking here to see links.It's \0... That's not true. In this example, you can pass something like Code: char name[] = "test";@shrink_tubing your getting the error because wc.lpszClassName is of the type LPCTSTR, your trying to assign it a wide character string. Instead of using Code: L"text"Code: TEXT("text");Although this particular problem wasn't a pointer issue, if you do have problems understanding pointers it would be a good idea to take NicolasKohr's advice and read up on them. As you will most likely get into it them in DirectX programming. Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. |
|||
|
« Next Oldest | Next Newest »
|






![[Image: adminexecuterh8.png]](http://img159.imageshack.us/img159/526/adminexecuterh8.png)
