PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Problem with UNICODE, VC6 & PocketFrog's loadimage?

This link in the general dev forum is the position so far
http://forums.pocketmatrix.com/viewtopic.php?t=9815
If I modify a VC6 project to be UNICODE I have to change the 3rd param in winmain from LPTSTR to LPSTR and I then get a linked error re: loadimagew which seems to be coming from a definition in winuser.h
As I still get the error even if I comment out the winuser.h definition of loadimage to loadimagew I'm not sure that I know how to proceed. Any suggestions.

( to recap, trying to build PF project in VC6 using unicode )
Ah, this is easy.. (or otherwise I've misunderstood the whole question and I appologize).

You mentioned earlier that you had problems compiling (or setting up) your project under VC6. I gave you some sugestions on that thread, but forgot to tell you this (I think) because I assumed you used TCHAR.

First of all, there is no need to modify the VC6 project to be UNICODE. I havn't done it, and I havn't got the slightest idea of how to to it either.

Just make shure you user the TCHAR and _T macros (defined in <tchar.h>) everywhere there are different functions (UNICODE and ANSI).

Like, for instance:
Code:
::MessageBox(0,_T("a message"),_T("info:"),MB_OK);


The LoadImage is a bit different, because here you also need to add the absolute path on WinCE, so there is really no point in using the _T macro. You could just as well use the L macro for WinCE code and no macro on VC6.

The problems with LoadImage also arrise because there is a standard win API function called LoadImage. This is why you should always use namespace quantifiers as often as possible, for instance: Frog::LoadImage() instead of LoadImage(). This will enshure that you are in fact using the LoadImage() from PocketFrog, and you won't get silly error messages generated from the win API (which can be very confusing if you don't know about this).

Like Orpe said on the other thread (hey, he's also from cold snowy sweden =) the linker links to different definitions according to wether UNICODE is defined by you project or not.. As I tried to illustrate with the ::MessageBox example above, it also is redefined to a ::MessageBoxW for UNICODE and a ::MessageBoxA for plain ASCII. But you don't have to keep track of this as long as you use the _T macro around all the input..

Pew.. hope this makes any sence..

I recon you could try to recompile the PocketFrog lib with the UNICODE option set, but as I'm trying to explain, this is not necessary (and probably will create other interesting problems).

In some cases (as I explained more thouroughly on the other thread where you requested help using VC6) you need to use special preprocessor defines to get around. In my project, there are not that many of these solutions, so I don't mind.. But I guess recompiling and defining the VC6 project to use UNICODE is a valid option, if you hate to see your code use preprocessor calls, and IF you know how to pull it of =)

Hope this helped ya out. Not shure that I answered your question, but atleast now you should be able to do a workaround..

AND, just to set things straight (for those who havn't got the faintest idea of what the TCHAR, _T and L macros do) here are some defines.

TCHAR and _T are platform dependant macros. And with platform I mean UNICODE or ANSI. On a UNICODE system, the TCHAR is translated into a wchar and on an ANSI system, a regular char. This is very handy.

The _T macro is used for static character string definitions and is used like this:
TCHAR tmp[] = _T("a string");

What this means is that on a UNICODE system it's interpreted (and linked by the compiler/linker) as:
wchar_t tmp[] = L"a string";

and on an ASCII system as:
char tmp[] = "a string";

And by this, it should be clear how the L macro is used.

(Sorry Conan if I got a bit sidetracked. Hopefully this thread will continue to be about your problem and not questions about TCHAR and string handeling)
Conan · 10 Feb 2003, 12:52 UTC — progress but getting linker errors
I started again following the advice above, no UNICODE definition, tchar.h included.

I built the PF lib for both release & debug & set the dependancy flag in my project.
My code compiles fine but I get linker errors.
Examples of them ( 9 in total )
game_menu.obj : error LNK2001: unresolved external symbol "public: void __thiscall Font::draw(class Frog::DisplayDevice *,__int32,__int32,unsigned __int32,char const *)" (?draw@Font@@QAEXPAVDisplayDevice@Frog@@_H1_IPBD@Z)

and

treker.obj : error LNK2001: unresolved external symbol "public: class Frog::Surface * __thiscall Font::getSurface(void)" (?getSurface@Font@@QAEPAVSurface@Frog@@XZ)


Update: For some stupid reason I had missed out some source includes which did not show at compile time? but only at link time.

I now have a built progect and just need to fix a few paths so I can try the thing out.

Update 2: Wow, my 3D goes so fast on a big PC.
It's magic to be able to debug properly again & not to have to worry about whether the emulator will work or not. Why didn't I do this sooner.

Many thanks to everyone for their assistance
adde · 10 Feb 2003, 14:39 UTC — progress but getting linker errors
Conan wrote:
Update 2: Wow, my 3D goes so fast on a big PC.
It's magic to be able to debug properly again & not to have to worry about whether the emulator will work or not. Why didn't I do this sooner.


Heh.. I thought so too, once I got everything to compile for both eVC and VC6. Debugging on the device is a HAZZLE, and productivity has risen through the roof (relative before switching to VC6 developing). Method warmly recommended to all users.

Conan wrote:
Many thanks to everyone for their assistance


Glad to be of service. I got some friendly pointers when I started out a few months ago and everything was new to me. So why not help others now when I know a possible solution.

I also want to thank all you guys who've helped me. This forum rules.