problem with cast

Discussion in 'C++' started by poiskaille, Aug 27, 2003.

  1. poiskaille

    poiskaille Guest

    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 ...
     
    poiskaille, Aug 27, 2003
    #1
    1. Advertising

  2. Re: problem with cast - [OT]

    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
     
    Gianni Mariani, Aug 27, 2003
    #2
    1. Advertising

  3. poiskaille

    Ryan Winter Guest

    Re: problem with cast - [OT]

    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 :p
     
    Ryan Winter, Aug 27, 2003
    #3
  4. poiskaille

    Andrew Ward Guest

    Re: problem with cast - [OT]

    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" <> wrote in message
    news:3f4c6b06$0$95047$...
    >
    >
    > 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 :p
    >
     
    Andrew Ward, Aug 27, 2003
    #4
  5. poiskaille

    Rolf Magnus Guest

    Re: problem with cast - [OT]

    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)
     
    Rolf Magnus, Aug 27, 2003
    #5
  6. Re: [OT]problem with cast

    "poiskaille" <> wrote in message
    news:3f4c5abc$0$266$...
    > 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.
     
    Josephine Schafer, Aug 27, 2003
    #6
  7. Re: [OT]problem with cast

    Josephine Schafer wrote:
    > "poiskaille" <> wrote in message
    > news:3f4c5abc$0$266$...


    > 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.
     
    Gianni Mariani, Aug 27, 2003
    #7
  8. Re: [OT]problem with cast

    "Gianni Mariani" <> wrote in message
    news:biid31$...
    > Josephine Schafer wrote:
    > > "poiskaille" <> wrote in message
    > > news:3f4c5abc$0$266$...

    >
    > > 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 :).
     
    Josephine Schafer, Aug 27, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rickman
    Replies:
    3
    Views:
    5,022
    rickman
    Jul 15, 2003
  2. Matt Tapia

    Specified cast is not valid Problem

    Matt Tapia, Jun 22, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    2,814
    Kevin Spencer
    Jun 24, 2004
  3. MSG

    to cast or not to cast malloc ?

    MSG, Feb 6, 2004, in forum: C Programming
    Replies:
    38
    Views:
    1,117
    Dan Pop
    Feb 10, 2004
  4. EvilRix
    Replies:
    8
    Views:
    678
    Martin Dickopp
    Feb 14, 2004
  5. Pavel
    Replies:
    7
    Views:
    561
    Pavel
    Sep 19, 2010
Loading...

Share This Page