Really Basic Question

Started by
2 comments, last by Clovermite24 17 years, 5 months ago
I'm trying to learn DirectX using Andre Lamothe's "Tricks of the Windows Game Programming Gurus." When I try to build a Directx application, I get a bunch of compiler errors. I posted about this problem last year, but at the time everyone told me to upgrade from Visual Studio 6. I've finally bought Visual Studio 2005, and now I still can't get it to compile. Here's what I've done: 1) Installed the directX sdk that came with the book (8.31) 2) Project-> Include Existing Item: for both ddraw.h and ddraw.lib 3)Tools->Options->VC ++ Directories->Include Files: for C:\DXSDK\include 4)Tools->Options->VC ++ Directories->Library Files: for C:\DXSDK\library There is one source file that has the following includes: #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <windowsx.h> #include <mmsystem.h> #include <ddraw.h> //more but I'm not sure they're relevant Here are the compiler errors I get: 5 under ...\VC\platformsdk\include\winnt.h: line 222 error C2146: syntax error: missing ';' before identifier 'PVOID64' line 222 error C4430: missing type specifier - int assumed. //etc with type Buffer 2 errors in the actual source file: error c2240L cannot convert from 'const char [10]' to 'LPCWSR' error C2663: "CreateWindowExW' : Cannot convert parameter 2 from 'const char [10] to 'LPCWSTR' What am I missing to get it to compile right? Do I just need to download the newest version of Directx? Thanks for your input ahead of time.
Advertisement
Most of those errors look like mixing char strings with unicode settings. VStudio2005 defaults to unicode. Right click your project, choose properties. Configuration Properties/General. The 3rd last option, change from unicode to multibyte.

I'm not sure what's causing the PVOID64 error, but you can try getting rid of the lean and mean define.
Well the bottom 2 errors inside the source file are because you're supplying ANSI strings when it wants UNICODE.

If you want the easy solution, go into your project settings, in Project Defaults, and find "Character Set"

Change this from "Use Unicode Character Set" to "Use Multi-Byte Character Set"

If the want the more-work-involved-but-better way, in your CreateWindowEx function you call, prefix the quotes for window text with an L.

Example:
CreateWindowEx(L"Something", blah, blah, blah);

As for the errors in the headers, make sure your code before the header is included all has the proper ending semi-colon. Even though the error isn't in the header, when the compiler reads it all, it can become confused, and I've had that same kind of problem with other headers.

Edit: Blast! I was beaten :D
Thanks for the quick responses, I really appreciate it.

The multi-byte character set definitely took care of the last two issues, but

I still don't quite understand the errors with winnt.h. For one thing, I'm using WinXP and none of my code references anything Winnt, unless it's referenced in windows.h or windowsx.h.

There is no code before the includes, so it has to be some sort of linker error or something.

I'm pretty sure I need the Lean_and_Mean define as the code uses macros included in that set and it avoids MFC.

I'm thinking it has something to do with the .net framework because I never had that problem with VS 6, and it's the exact same code.

Any other ideas?

Again, I really appreciate the input. I'm a beginner-intermediate programmer trying to learn this stuff, so I'm not incredibly familiar with all the compiler details.

This topic is closed to new replies.

Advertisement