Primary Advices for Migration from ObjectARX 2004-6 to ObjectARX 2007-8
来源:互联网 发布:名校情结 知乎 编辑:程序博客网 时间:2024/06/06 06:36
The original file is at:http://private.peterlink.ru/poleshchuk/cad/2006/M2007-prime.htm
N.Poleshchuk. Primary Advices for Migration from ObjectARX 2004-6 to ObjectARX 2007-8
Basic Differences Between ARX Projects 2004/2005/2006 and 2007
The main thing: applications for AutoCAD 2007 and higher must support unicodes, in other words every alphanumeric symbol will be coded by two bytes not by one as in the usual ANSI coding. Let us declare the most obvious differences:
N Name AutoCAD 2004/2005/2006 AutoCAD 2007 1 String data type char *
char [] wchar_t *
wchar_t [] 2 Explicitely defined strings "Sample string" L"Sample string" 3 String functions _itoa(), ... _itow(), ...
But there are many other less obvious distinctions that can be discovered while reorganizing your applications to the next version. Some of them are mentioned in the file ObjectARX 2007/docs/acad_xmg.chm ("ObjectARX Migration Guide").
Simple Advices for Writing Source Code of ARX Applications for AutoCAD 2004/2005/2006 and AutoCAD 2007
It would be good to create source texts in a manner suitable to include them without changes into appplications for dif-ferent versions of AutoCAD. Taking into account that in versions 2004-2007 ObjectARX Wizard creates project skeleton by similar templates it is possible to write programs in a universal form. All the differences will be hidden in linked header files and libraries that mostly preserve their names from version to version. In theory it is also possible to create texts satisfying previous versions (2002, 2000i, 2000) but for them ObjectARX Wizard uses another template - that-s why we will not consider the extension of source texts to these versions (possible but harder).
The three primary migration differences for C++ were formulated above. Next you will find recommendations for each of them.
The ACHAR Data Type
This type is defined in the AdAChar.h file of ObjectARX 2006 in the following way:
typedef char ACHAR;
In the 2007th version ACHAR declaration looks otherwise:
typedef wchar_t ACHAR;
So we can conclude that in the both versions it is convenient instead of char and wchar_t to use the universal ACHAR type for which you should put into text a directive:
#include "AdAChar.h"
It will provide program text uniformity in declaration of string variable types for 2006 and 2007. Therefore it is possible to build applications for AutoCAD 2004/2005/2006 using ObjectARX 2006 (it is necessary indeed to make sure of workability of your ARX files in AutoCAD 2004/2005 if application should run in these versions too).
In ObjectARX 2005 there is no AdAChar.h file but ACHAR type declaration can be found in adesk.h. If you be more attentive then you will see that there is an include instruction for AdAChar.h file in it. That-s why it is better to attach adesk.h rather than AdAChar.h:
#include "adesk.h"
Macros from TCHAR.H
The tchar.h file was inserted by Microsoft into Visual C++ to facilitate application transferring to unicodes support.
If the source text has a directive
#include <tchar.h>
then macros from tchar.h file become available to Visual C++ preprocessor working before compilation.
The _T Macro
First of all the _T macro is interesting for us. If the following directive
#define _UNICODE
is present then L character is added before (this is what we just need for explicitely defined unicode string constants). At the same time if the identifier _UNICODE is defined then _T macro does nothing (leaves argument unchanged).
Example:
acutPrintf(_T("Design system, 2007."));
Info. In Visual C++ 2005 the _UNICODE identifier is always set by default.
String Function Macros
The tchar.h file contains many macros corresponding to the functions handling strings. For example:
Macro ANSI function Unicode function _itot _itoa _itow _ttoi atoi _wtoi _ttol atol _wtol _tstof atof _wtof _tcslen strlen wcslen _tcscat strcat wcscat _tcscpy strcpy wcscpy _tcsncpy strncpy wcsncpy
Therefore instead of string functions in a universal source code it is better to use macros that is being transformed by preprocessor to specific function names (ANSI or Unicode).
Note 1. Some functions (e.g. strcat) in Visual C++ 2005 are treated as depricated because of safe analogs creation (strcat_s).
Note 2. Many Windows API functions in reality have two types, for ANSI and Unicode, that is compiler itself appends A or W symbol. For example, MessageBoxA and MessageBoxW.
Preprocessor Directives
For outdated functions and for other cases when macros from tchar.h are unsufficient you can use directives that are run by preprocessor before compilation of source code. Pieces of texts that should look different with supporting unicodes and without it are formed by #ifdef and #ifndef directives. Here is an example:
#ifdef _UNICODE
_tcscat_s (s1, s2);
#else
_tcscat (s1, s2);
#endif
In this example a new safe function wcscat_s will be included into the text for AutoCAD 2007 (Visual C++ 2005) and an older one strcat function for AutoCAD 2005 (Visual C++ 2002).
Such a branching will help you to take into account all the features of AutoCAD 2007 in comparison with the older versions (e.g. to create mesh in version 2006 and to create surface in version 2007 or higher).
In the same way but with the user identifiers for preprocessor one can make branching for various languages (Russian-English etc.), and for 64-bit support.
We are talking here of some problems arising while migrating from ObjectARX 2006 (and 2004/2005) to ObjectARX 2007 (and 2008).
- Primary Advices for Migration from ObjectARX 2004-6 to ObjectARX 2007-8
- ObjectARX
- ObjectARX:C# ObjectARX--起步
- ObjectARX下载ObjectARX Wizards
- 急求ObjectARX for AutoCAD 2008
- ObjectARX简介
- ObjectARX 介绍
- ObjectARX-圆
- 关于objectarx
- ObjectARX 概述
- ObjectARX 类库
- ObjectARX简介
- ObjectARX:C# ObjectARX--关于实体
- Migration from Qmail to Zimbra
- ObjectARX文档设置和ObjectARX标准程序
- .net 开发ObjectARX 学习
- ObjectARX 足球算法
- ObjectARX开发Autocad
- 博客搬家到CSDN
- Windows基本的数据类型
- 为什么开源产业不同于沃尔玛
- 咖啡只是一种习惯
- Migration Advice - AcString Type
- Primary Advices for Migration from ObjectARX 2004-6 to ObjectARX 2007-8
- C#精髓【月儿原创】第二讲 WMI完美秀出CPU编号厂商主频百分比等全部信息
- 职场行为准则
- 堆和栈的区别
- 《设计模式解析》摘录(9)
- ANSI与UNICODE
- Just a kidding--how to test a match
- Linux-C-Socket编程
- 追根究底,剖析MFC六大关键技术(一)