Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Whats wrong with this LPCTSTR name = "Runner"? possible visual c++ 2005b2 problem?

This topic is 4880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi in my c++ program ive got: #define WIN32_MEAN_AND_LEAN #include <windows.h> #define CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <string> #include <sstream> #include <vector> #include <fstream> #include <iostream> #include <iomanip> LPCTSTR name = "Runner"; and im getting the error:
Quote:
error C2440: 'initializing' : cannot convert from 'const char [7]' to 'LPCTSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
i can't work out why its doing this. Im using the visual c++ 2005 beta 2 edition, under 'console application' because for some reason i can't select win32 app in the project creation window, which might be causing this problem? thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try to use:
LPCTSTR name = (LPCTSTR)"Runner";

Share this post


Link to post
Share on other sites
Quote:
Original post by johnnyBravo
i can't work out why its doing this. Im using the visual c++ 2005 beta 2 edition, under 'console application' because for some reason i can't select win32 app in the project creation window, which might be causing this problem?


Take a look at my post here and a few above to see why. If you are not using the express edition, you should be able to make a Win32 app - you make a console app project, but then choose the 'Application Settings' option on that final screen before the project is made and choose Win32. Given that, you should have the platform SDK downloaded and installed as well.

As for the code, I think you have to do something like:
LPCTSTR name = _T("Runner"); or something like that to assign a literal to a pointer. This is probabally because either LPCSTR was redefined in the new SDK, or something like that. Also try a LPCTSTR name = reinterpret_cast<LPCTSTR>("Runner") as well. Good luck!

[edit]Or what AP said [smile]

Share this post


Link to post
Share on other sites
_T("Runner"); didnt work, while the others did, the caption for my window looks like a solid white rectangle tho.

Ok I fixed the win32 app thanks to your post, but its kinda weird. In projects I made from beta 1, they work fine, eg i can just use:
wc.lpszClassName = "Runner";
or:
HWND hwnd = CreateWindow(wc.lpszClassName, "The caption",...


and these work fine.

its when I try the same thing in beta 2 created project, i ge the error i posted above. any ideas on what happening here?

Thanks

Share this post


Link to post
Share on other sites
Welcome to the cluster-f*** that is #define _UNICODE.

Quote:
#define WIN32_MEAN_AND_LEAN

It's #define WIN32_LEAN_AND_MEAN

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!