Browse DevX
Sign up for e-mail newsletters from DevX


Porting Visual C++ Code to Visual Studio 2005-3 : Page 3




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Just in the Nick of Time
Visual Studio 2005 and Visual C++ 6.0 have different Application Binary Interfaces, or ABIs. This means that the same datatype or function may have different binary layouts and mangled names. The different ABIs affect among other things the std::time_t and wchar_t datatypes.

Visual C++ 6.0 treats std::time_t as a 32-bit integer, whereas in Visual Studio 2005 this type is a 64-bit integer. This change might necessitate code updates if your app assumes a 32-bit time_t e.g., hard-coded buffer sizes and format flags (further information on migrating to 64-bit code is available here). Another ABI change affects the representation of the wchar_t type. Up until now, wchar_t has been a typedef synonymous with unsigned short. However, Visual Studio 2005 treats wchar_t as a built-in type. This change might affect the overload resolution of functions:

int _wtolowers(unsigned short *ws); wchar_t ws[10] = L"Test"; _wtolowers(ws);

This code compiles with Visual Studio 6.0 but it will break with Visual Studio 2005 because wchar_t * is incompatible with unsigned short *.

All and Sundry
The changes described here affect not just Visual C++ 6.0 code ported to Visual Studio 2005. Rather, they apply to legacy C++ code ported to an ISO compliant C++ compiler in general. The fear from these changes has led many project managers to defer upgrades at all costs. This policy isn't justified, though. Almost without exception, these changes are only for the best.

Danny Kalev is a certified system analyst and software engineer specializing in C++. He was a member of the C++ standards committee between 1997 and 2000 and has since been involved informally in the C++0x standardization process. He is the author of "The ANSI/ISO Professional C++ Programmer's Handbook" and "The Informit C++ Reference Guide: Techniques, Insight, and Practical Advice on C++."
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date