Page 1 of 1
Strange compile errors

Posted:
Jun 27, 2001 @ 12:39pm
by Daywalker
If im putting something like this in my sourcecode (using eMB 3.0):<br><br><br>sndPlaySound("sound.wav", SND_LOOP | SND_FILENAME); <br><br><br><br>I get this error:<br><br><br>error C2664: 'sndPlaySoundW' : cannot convert parameter 1 from 'char [10]' to 'const unsigned short *'<br><br><br>If im programming with VC++ 6.0 for Windows 95... (using PlaySound), everything works fine.<br>The problem also appears with MessageBoxes.<br>What's the problem?
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 12:45pm
by Moose or Chuck
You can't name a wav file like that. You have to use something like: MAKEINTRESOURCE(IDR_WAVE1).<br>(in which case you imported the wave into your resource file and gave it that ID in the resource's header file)<br>Last modification: Moose Master - 06/27/01 at 09:45:45
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 12:46pm
by Moose or Chuck
But I can't get playsound to work at all. It gives me some linking error whenever I try. (also getting rid of new bug). See my other thread (Linking Error), I need some help on that.
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 1:20pm
by Malmer
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 1:24pm
by Moose or Chuck
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 1:28pm
by jongjungbu
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 1:32pm
by jongjungbu
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 6:27pm
by Dan East
As Fredrick basically said, you need to pass a UNICODE string instead of ASCII. You can place an L in front of the string, but I greatly prefer using the _T( "" ) macro instead because it follows standard C syntax which looks and makes more sense than using the L macro. The following are are methods of forcing the compiler to convert a string to unicode:<br>_T( "my string" ), L"my string", _TEXT( "my string" )<br>Using the L macro is also more "dangerous" in that it always converts to a Unicode string. _T and _TEXT will only convert the string if you are building a Unicode app, which makes your code more portable. If you use the L macro then you should not use _t functions. You should use the _w family instead since you are specifically using only wide-character strings.<br><br>You do not use the SND_FILENAME flag. sndPlaySound will load the file if that is what your string refers to.<br><br>Dan East<br><br>Friggen smileys: Last modification: Dan East - 06/27/01 at 15:27:48
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 6:28pm
by jongjungbu
So yer pretty much saying my sample code was right!!!

Re: Strange compile errors

Posted:
Jun 27, 2001 @ 6:49pm
by Dan East
Yep, sorry JJB, I basically said exactly what you did. As Moose will tell you, I'm good at that.

<br><br>Dan East
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 7:01pm
by Moose or Chuck
And now that the question is answered by Dan there will be no more replies to this thread.<br>Either Dan is really good at answering questions, or he has a disease we don't know about.
Re: Strange compile errors

Posted:
Jun 27, 2001 @ 7:04pm
by jongjungbu
I will reply anyway.<br>Heh. That is okay by me Dan. I'm just enjoying that you have confirmed what I posted. Then I can say..."In your Face!" <br><br>umm, i just dont know who i can say that to though.