- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to share some experience on porting a C/C++ project to a 64-bit platform. It was started last week and I already
have lots of different problems.
Here is a list of Tips, Detected Problems and Issues:
1. I recommend to take a look at the following topics on MSDN if you're about to start a 64-bit programming:
"Platform SDK: 64-bit Windows Programming"
"Migration Tips"
"64-Bit Programming with Visual C++"
"How to: Configure Projects to Target Platforms"
2. Turn on a /Wp64 compiler option for Microsoft compatible C++ compilers. It detects 64-bit
portability problems on types that are marked with the __w64 keyword;
3. Issue - LONGLONG data type:
...
#if !defined( _M_IX86 )
typedef __int64 LONGLONG;
#else
typedef double LONGLONG;
#endif
...
4. Issue - Date & Time CRT-functions and data types
5. Issue - A 'size_t' type is used in 'new' C++ operators to pass a size of a memory to allocate and
it is 8-bytes long on a 64-bit platform
6. Microsoft C++ compiler ( a test case ):
...
int iInt32 = 0xffffeeeeddddcccc; // -> iInt32 = 0xddddcccc - This is simplya verification of truncation
...
7. Problem - MinGW C++ compiler ( a test case ):
...
int iInt32 = 0xffffeeeeddddcccc; // -> Error: integer constant is too large for "long" type
...
8. Use explicit 'ifdef's for different platforms ( pseudo codes ):
...
#ifdef _16BIT_PLATFORM_
//...
#endif
#ifdef _32BIT_PLATFORM_
//...
#endif
#ifdef _64BIT_PLATFORM_
//...
#endif
...
9. Default ( turn on ) the following warnigs for Microsoft compatible C++ compilers:
#pragma warning ( default : 4239 )// Nonstandard extension used : 'type cast' : conversion from 'type1' to 'type2'
#pragma warning ( default : 4242 )// Conversion from 'type1' to 'type2', possible loss of data
#pragma warning ( default : 4244 )// Conversion from 'type1' to 'type2', possible loss of data
#pragma warning ( default : 4305 )// 'Initializing' : truncation from 'type1' to 'type2'
#pragma warning ( default : 4309 )// 'Initializing' : truncation of constant value
#pragma warning ( default : 4311 )// 'Type cast' : pointer truncation from 'type1' to 'type2'
10. Verify how the __w64 keyword works for Microsoft compatible C++ compilers:
// Test Case - Verification of __w64 keyword - based on MSDN example
// 'V64C' stands for 'Verify 64-bit Compatibility'
...
#if ( defined ( _WIN32_MSC ) || defined ( _WIN32_ICC ) )
#define _RTV64C__w64
#endif
#if ( defined ( _WIN32CE_MSC ) || defined ( _WIN32_BCC ) || defined ( _WIN32_MGW ) ||\\
defined ( _COS16_TCC ) )
#define _RTV64C
#endif
...
#pragma warning ( default : 4244 )// Conversion from 'type1' to 'type2', possible loss of data
#define _WIN64
//#undef _WIN64
typedef int Int_32;
#ifdef _WIN64
typedef __int64 Int_Native;
#else
typedef int _RTV64C Int_Native;
#endif
Int_32 iInt_32 = 0xffeeddcc;
Int_Native iInt_Native = 0xffffeeeeddddcccc;
iInt_32 = iInt_Native; // MSDN - Warning C4244: 64-bit int assigned to 32-bit int
// Compiler - Warning C4244: '=' : conversion from 'Int_Native' to 'Int_32', possible loss of data
#undef _WIN64
#pragma warning ( disable : 4244 )
...
11. If a project has Test Cases ALL of them must be verified on a 64-bit platform
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:Ok:) @Sergey Do you do any kind of driver development?>>...Microsoft did a good job of integrating and combining driver development with Visual Studio IDE...
Please take into account that the subject of the thread is Tips for Porting software to a 64-bit platform and it is not related to porting drivers to a 64-bit Windows platform(s).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page