problem with cast

P

poiskaille

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 ...
 
G

Gianni Mariani

poiskaille said:
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
 
R

Ryan Winter

Gianni said:
poiskaille said:
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 :p
 
A

Andrew Ward

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 said:
Gianni said:
poiskaille said:
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 :p
 
R

Rolf Magnus

Andrew said:
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)
 
J

Josephine Schafer

poiskaille said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top