Thread: Converting MSVC7 to MSVC8 strings

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    Converting MSVC7 to MSVC8 strings

    First let me say that I am not a C++ programmer. I dabble a little in VB and a lot in Lisp for AutoCAD. I have a program that was written for me in C++ for AutoCAD and I was trying to recompile it using a newer version of C++ than it was written in and I have several of these errors.

    char kwd [128];
    char msg [128];
    char prompt [128];
    double def;
    char ctemp [64];
    struct resbuf *rb;
    rb = ads_getargs();

    strncpy (kwd,rb->resval.rstring,sizeof (kwd) - 1);
    strncpy (msg,rb->resval.rstring,sizeof (msg) - 1);
    error C2644: cannot convert parameter 2 from 'ACHAR *' to 'const char *'

    def = atof (rb->resval.rstring);
    error C2644: cannot convert parameter 1 from 'ACHAR *' to 'const char *'


    if (ads_getvar ("LUPREC",&rb_var) == RTNORM)
    error C2644: cannot convert parameter 1 from 'const char [7]' to 'ACHAR *'

    ads_rtos (def,4,4,ctemp);
    ads_rtos (def,2,lprec,ctemp);
    error C2644: cannot convert parameter 4 from 'char [64]' to 'ACHAR *'

    stat = ads_initget (bit,kwd);
    stat = ads_getstring (0,prompt,ctemp);
    error C2644: cannot convert parameter 2 from 'char [128]' to 'const ACHAR *'

    stat = ads_getreal (prompt,&value);
    error C2644: cannot convert parameter 1 from 'char [128]' to 'const ACHAR *'

    ads_getinput (ctemp);
    ads_retstr (ctemp);
    error C2644: cannot convert parameter 1 from 'char [64]' to 'const ACHAR *'

    ads_rtos (value,2,4,ctemp);
    ads_rtos (value,2,2,ctemp);
    error C2644: cannot convert parameter 4 from 'char [64]' to 'ACHAR *'

    str = rb->resval.rstring;
    error C2644: '=': cannot convert from 'ACHAR *' to 'char *'

    Like I said. I don't know anything about C++ so any answers need to be clear enough for a dummy.
    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Do you ever want to go back to your old compiler?
    Compilers like visual studio offer a bunch of macros which make swithing character types a lot easier, once you've taken the hit to make your code compatible with both.


    char kwd [128];
    to
    ACHAR kwd [128];

    and
    if (ads_getvar ("LUPREC",&rb_var) == RTNORM)
    to
    if (ads_getvar (L"LUPREC",&rb_var) == RTNORM)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    2
    char kwd [128];
    to
    ACHAR kwd [128];


    Sorry but this does not work for me. ACHAR is not recognized. Is there another way or how do I get ACHAR to be a legal type?

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Maybe try using TCHAR and wrapping all occurrences of literal strings in the TEXT() macro.
    Unfortunately, if you use any of the standard string manipulation functions you need to switch to the appropriate TCHAR versions, whose names are incredibly cryptic and are preceded by an underscore (_tscanf, _tcscat, _tcscmp, etc...).

    I've never heard of the ACHAR type and googling turned up nothing of interest. Sorry.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting strings to char
    By Furious5k in forum C++ Programming
    Replies: 13
    Last Post: 01-02-2009, 05:26 PM
  2. Converting strings to chars
    By Suchy in forum C++ Programming
    Replies: 4
    Last Post: 05-06-2007, 04:17 AM
  3. converting a vector of strings into an array.
    By LightsOut06 in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 07:14 PM
  4. converting c style strings to c++ strings
    By fbplayr78 in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 03:13 AM
  5. converting strings to ints
    By HomerJ in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2002, 06:08 PM