Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > problem with cast

Reply
Thread Tools

problem with cast

 
 
poiskaille
Guest
Posts: n/a
 
      08-27-2003
Hi,

I work with VisualC++ and I'va got this error while I'm trying to compile a
project found on the Net (odbcsocketserver.sourceforge.net):

cannot convert parameter 1 from char [10] to const unsigned short, cast
needed ...
....
....

my function looks like:
my_fonction(LPCTSTR param)
and calls looks like:
my_fonction("blablabla");

thanks ...


 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      08-27-2003
poiskaille wrote:
> Hi,
>
> I work with VisualC++ and I'va got this error while I'm trying to compile a
> project found on the Net (odbcsocketserver.sourceforge.net):
>
> cannot convert parameter 1 from char [10] to const unsigned short, cast
> needed ...
> ...
> ...
>
> my function looks like:
> my_fonction(LPCTSTR param)


What is a LPCTSTR ?

Whatever it is it's not standard C++ and it's not a char * !

> and calls looks like:
> my_fonction("blablabla");
>
>



hint look up "_T()"

BTW - this is off topic in this ng.

You will have better luck in the MS newsgroups.

Also, next time submit compilable code (or in this case a complete
example that you think should compile.

G

 
Reply With Quote
 
 
 
 
Ryan Winter
Guest
Posts: n/a
 
      08-27-2003


Gianni Mariani wrote:
> poiskaille wrote:
>
>> Hi,
>>
>> I work with VisualC++ and I'va got this error while I'm trying to
>> compile a
>> project found on the Net (odbcsocketserver.sourceforge.net):
>>
>> cannot convert parameter 1 from char [10] to const unsigned short, cast
>> needed ...
>> ...
>> ...
>>
>> my function looks like:
>> my_fonction(LPCTSTR param)

>
>
> What is a LPCTSTR ?


I think its an const unsigned short

 
Reply With Quote
 
Andrew Ward
Guest
Posts: n/a
 
      08-27-2003
typedef char TCHAR
typedef const TCHAR* LPCTSTR

The above definitions are straight from the windows headers, so as long as
your compiling for ascii it's just a 'const char *'
go figure!


"Ryan Winter" <(E-Mail Removed)> wrote in message
news:3f4c6b06$0$95047$(E-Mail Removed)...
>
>
> Gianni Mariani wrote:
> > poiskaille wrote:
> >
> >> Hi,
> >>
> >> I work with VisualC++ and I'va got this error while I'm trying to
> >> compile a
> >> project found on the Net (odbcsocketserver.sourceforge.net):
> >>
> >> cannot convert parameter 1 from char [10] to const unsigned short, cast
> >> needed ...
> >> ...
> >> ...
> >>
> >> my function looks like:
> >> my_fonction(LPCTSTR param)

> >
> >
> > What is a LPCTSTR ?

>
> I think its an const unsigned short
>



 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      08-27-2003
Andrew Ward wrote:

> typedef char TCHAR
> typedef const TCHAR* LPCTSTR
>
> The above definitions are straight from the windows headers, so as
> long as your compiling for ascii it's just a 'const char *'
> go figure!


And how do you explain this:

>> >> cannot convert parameter 1 from char [10] to const unsigned short,

^^^^^^^^^^^^^^^^^^^^
>> >> cast needed ...
>> >> ...
>> >> ...
>> >>
>> >> my function looks like:
>> >> my_fonction(LPCTSTR param)


 
Reply With Quote
 
Josephine Schafer
Guest
Posts: n/a
 
      08-27-2003

"poiskaille" <(E-Mail Removed)> wrote in message
news:3f4c5abc$0$266$(E-Mail Removed)...
> Hi,
>
> I work with VisualC++ and I'va got this error while I'm trying to compile

a
> project found on the Net (odbcsocketserver.sourceforge.net):
>
> cannot convert parameter 1 from char [10] to const unsigned short, cast
> needed ...
> ...
> ...
>
> my function looks like:
> my_fonction(LPCTSTR param)
> and calls looks like:
> my_fonction("blablabla");
>
> thanks ...


This minimal code compiles for me on VC 7.0 without any warning/errors.

#include <windows.h>
void my_fonction(LPCTSTR param)
{
}
int main ()
{
my_fonction("blablabla");
}

Which complier do you use or may be I am missing on something.


 
Reply With Quote
 
Gianni Mariani
Guest
Posts: n/a
 
      08-27-2003
Josephine Schafer wrote:
> "poiskaille" <(E-Mail Removed)> wrote in message
> news:3f4c5abc$0$266$(E-Mail Removed)...


> This minimal code compiles for me on VC 7.0 without any warning/errors.
>
> #include <windows.h>
> void my_fonction(LPCTSTR param)
> {
> }
> int main ()
> {
> my_fonction("blablabla");
> }
>
> Which complier do you use or may be I am missing on something.
>
>


Try a "release mode" build.

 
Reply With Quote
 
Josephine Schafer
Guest
Posts: n/a
 
      08-27-2003

"Gianni Mariani" <(E-Mail Removed)> wrote in message
news:biid31$(E-Mail Removed)...
> Josephine Schafer wrote:
> > "poiskaille" <(E-Mail Removed)> wrote in message
> > news:3f4c5abc$0$266$(E-Mail Removed)...

>
> > This minimal code compiles for me on VC 7.0 without any warning/errors.
> >
> > #include <windows.h>
> > void my_fonction(LPCTSTR param)
> > {
> > }
> > int main ()
> > {
> > my_fonction("blablabla");
> > }
> >
> > Which complier do you use or may be I am missing on something.
> >
> >

>
> Try a "release mode" build.


Works with both debug as well as release builds for me .


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is the result of valid dynamic cast always equal to the result ofcorrespondent static cast? Pavel C++ 7 09-18-2010 11:35 PM
error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Abhijit Bhadra C++ 2 12-01-2004 04:43 PM
malloc - to cast or not to cast, that is the question... EvilRix C Programming 8 02-14-2004 12:08 PM
to cast or not to cast malloc ? MSG C Programming 38 02-10-2004 03:13 PM
Quartus VHDL problem with aggregate and type cast rickman VHDL 3 07-15-2003 04:24 AM



Advertisments