VC8 - ObjectARX 7 - ACHAR *

VC8 - ObjectARX 7 - ACHAR *

Anonymous
Not applicable
2,072 Views
7 Replies
Message 1 of 8

VC8 - ObjectARX 7 - ACHAR *

Anonymous
Not applicable
I'm trying to move my ARX application from VC7 and AutoCAD2006 to VC8 and
AutoCAD2007

In this line (an similar ones):

ads_printf( "< %d,%d >\n",n[0],n[1] );

I get this error message

error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char
[11]' to 'const ACHAR *'

I know that VC8 and ARX2007 use unicode strings, but how can I fix this
problem without changing my code?
thanks
0 Likes
2,073 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
> I know that VC8 and ARX2007 use unicode strings, but how can
> I fix this problem without changing my code?

There is no way to fix it without changing your code. Is there some
reason why you can't change your code? 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 3 of 8

Anonymous
Not applicable
I mean not to change every single line, because:

a) This problem exists in more that 3000 cases in my project (mainly because
of ads_printf, or strcpy, strlen, etc)

b) I use the same-common code for building the project for AutoCAD R14 -
AutoCAD 2006

Perhaps by changing project setings or definitions?
thank you

ps.. sorry.. i pressed the wrong button and replied in a wrong way...

"Owen Wengerd" wrote in message
news:5182932@discussion.autodesk.com...
> I know that VC8 and ARX2007 use unicode strings, but how can
> I fix this problem without changing my code?

There is no way to fix it without changing your code. Is there some
reason why you can't change your code? 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 4 of 8

Anonymous
Not applicable
I'm afraid you'll have to fix your code. If you haven't written macros in
Visual Studio, this would be a good reason to learn. Spend an hour or two
writing a macro to wrap your constant strings in ACRX_T(), then you will
have fixed your code and learned a new trick at the same time. For
targeting previous versions of AutoCAD, just:
#define ACRX_T(s) s
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 5 of 8

Anonymous
Not applicable
Furthermore, there is a whole collection of _t macros provided my Microsoft
(e.g., _tcslen()) that (mostly) enable you to write single-source MBCS and
UNICODE code.

Although IMHO, MBCS is *far* too much trouble, so if you're forced to make
changes anyway, do everything in UNICODE (no ugly _t macros) internally and
convert at the edges (assuming you can live with the slight performance
hit). Of course, this assumes you want/need a MBCS application (usually for
CJK); if you're satisfied with just ISO8859-1 languages (western europe),
then you don't need UNICODE.

Dan

"Owen Wengerd" wrote in message
news:5182955@discussion.autodesk.com...
I'm afraid you'll have to fix your code. If you haven't written macros in
Visual Studio, this would be a good reason to learn. Spend an hour or two
writing a macro to wrap your constant strings in ACRX_T(), then you will
have fixed your code and learned a new trick at the same time. For
targeting previous versions of AutoCAD, just:
#define ACRX_T(s) s
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 6 of 8

Anonymous
Not applicable
Hi,

We can adapt following two solutions to fix ur problem:
Solution 1:
1. Change your project settings to UNICODE.
2. Wrap every string literals using _T or ACRX_T macro;
3. Replace standard string functions with UNICODE string functions
e.g strcpy by _tcscpy. Find and replace can do this job easily 🙂

Solution 2:
1. Keep previous settings as it is.
2. Handle only functions that deal with AutoCAD 2007.
e.g ads_printf" hello") change it to ads_printfACRX_T(" hello"))
3. Convert strings to UNICODE for AutoCAD dealing functions.
5. Convert strings got from AutoCAD back to ANSI for dealing with your original functions taking ANSI string parameters.

It is always advisable to use solution 1.
Please let me know if you have any questions further.

Thanks and Best Regards,
KIMI
0 Likes
Message 7 of 8

Anonymous
Not applicable
Hi,

I am also facing the same kind of problem. I am very new to AutoCad and C++. In my company they used one application. Its work fine on AutoCad 2005 but it will not working in AutoCad 2008. I plan to convert that application. I created a new application in Visual studio environment, download the latest objectarx include and library file. Now i am facing so many error, could you please give solution for my problem.
I list out the errors.
Error 1 error C2664: 'acedDefun' : cannot convert parameter 1 from 'char *' to 'const ACHAR *'
Error 2 error C2664: 'acedUndef' : cannot convert parameter 1 from 'char *' to 'const ACHAR *'
Error 3 error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [12]' to 'const ACHAR *'
Error 4 error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [25]' to 'const ACHAR *'
Error 5 error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [8]' to 'const ACHAR *'
Error 6 error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [8]' to 'const ACHAR *'
Error 7 error C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [8]' to 'const ACHAR *'
Error 8 error C2440: '=' : cannot convert from 'char [24]' to 'ACHAR *'
Error 9 error C2440: '=' : cannot convert from 'char [24]' to 'ACHAR *'
Error 10 error C2440: '=' : cannot convert from 'char [24]' to 'ACHAR *'

So i try to change that data type as ACHAR the error was retified but it wont work in AutoCad. Please help me...
I was stuckup with this problem. I here with attach that code, for your refernce.
0 Likes
Message 8 of 8

Anonymous
Not applicable

You need to do some research on UNICODE. 
UNICODE characters are 2-byte characters.  Starting with AutoCAD 2007,
AutoCAD is now fully UNICODE compatible.  That means that all of your
strings and characters need to be defined as such.  For example, if you
include "tchar.h" into your project you can then replace your char definitions
with TCHAR definitions;

 

char szName[21];  becomes TCHAR
szName[21];

 

Your literal strings would be wrapped with the _T()
macro;

 

acutPrintf( "Command finished successfully\n" );
becomes acutPrintf( _T("Command finished successfully\n"));

 

It's fairly straight forward, but beware ... if you
are storing old char variables in a binary format somewhere, then you will need
to extract it as a char and use "mbstowcs()" to convert to a wide character
string (that's what both ACHAR and TCHAR are) if you are going to use it with
any of the AutoCAD API calls.

 

Joe


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
I am also facing the same kind of problem. I am very new to AutoCad and C++.
In my company they used one application. Its work fine on AutoCad 2005 but it
will not working in AutoCad 2008. I plan to convert that application. I
created a new application in Visual studio environment, download the latest
objectarx include and library file. Now i am facing so many error, could you
please give solution for my problem. I list out the errors. Error 1 error
C2664: 'acedDefun' : cannot convert parameter 1 from 'char *' to 'const ACHAR
*' Error 2 error C2664: 'acedUndef' : cannot convert parameter 1 from 'char *'
to 'const ACHAR *' Error 3 error C2664: 'acutPrintf' : cannot convert
parameter 1 from 'const char [12]' to 'const ACHAR *' Error 4 error C2664:
'acutPrintf' : cannot convert parameter 1 from 'const char [25]' to 'const
ACHAR *' Error 5 error C2664: 'acutPrintf' : cannot convert parameter 1 from
'const char [8]' to 'const ACHAR *' Error 6 error C2664: 'acutPrintf' : cannot
convert parameter 1 from 'const char [8]' to 'const ACHAR *' Error 7 error
C2664: 'acutPrintf' : cannot convert parameter 1 from 'const char [8]' to
'const ACHAR *' Error 8 error C2440: '=' : cannot convert from 'char [24]' to
'ACHAR *' Error 9 error C2440: '=' : cannot convert from 'char [24]' to 'ACHAR
*' Error 10 error C2440: '=' : cannot convert from 'char [24]' to 'ACHAR *' So
i try to change that data type as ACHAR the error was retified but it wont
work in AutoCad. Please help me... I was stuckup with this problem. I here
with attach that code, for your refernce.
0 Likes