A common error occurring when compiling a 64-bit application: error C2440, OnTimer

One of the most common errors a programmer encounters when porting applications from a Win32 system to a Win64 one is the error related to the function OnTimer. The function OnTimer is used nearly in every application and you are likely to get some compilation errors. Earlier this function had the prototype “OnTimer(UINT nIDEvent)” and is most likely to be present in user classes in the same form. Now this function has the prototype “OnTimer(UINT_PTR nIDEvent)” and it causes a compilation error for the 64-bit system.

Continue reading

C++11 and 64-bit Issues

64-bit computers have been around for a long time already. Most applications have 64-bit versions that can benefit from a larger memory capacity and improved performance, thanks to the architectural capabilities of 64-bit processors. Developing a 64-bit application in C/C++ requires a great deal of attention from a programmer. There are a number of reasons for 32-bit code to fail to work properly when recompiled for the 64-bit platform. There are a lot of articles on this subject, so we will focus on another point. Let’s find out if the new features introduced in C++11 have made 64-bit software programmers’ life any better, or easier.

Без названия

Continue reading

20 issues of porting C++ code to the 64-bit platform

This article describes the process of porting a 32-bit application to 64-bit systems. The article is written for programmers who use C++ but it may also be useful for all who face the problem of porting applications onto other platforms. The authors are creators of PVS-Studio static analyzer that is a great help in the task of porting programs to the 64-bit platform.

^3A30F77AF0C5FAA6698E4F6939A8DFB436FF1CCD7E3EDE56CC^pimgpsh_fullsize_distr

Continue reading

Big Brother is helping you

Once more I got reassured that programmers write programs absolutely carelessly, so that their programs work not because of their skill but due to chance and care of Microsoft or Intel compiler developers. Right, it is them who really care and put crutches under our lop-sided programs when necessary.

Here is a byte-breaking story of the CString class and daughter of it, the Format function.

Big_Brother_15_-_2014_-_Eye_Logo_-_HQ_-_White_Background

Continue reading

Change of type alignment and the consequences

When porting software one of the task a developer faces is to change types’ sizes and rules of their alignments.

Once my attention was attracted by a message in RSDN forum:

Today I have faced a problem in Linux. There is a data structure consisting of several fields: 64-bit double, 8 unsigned char and one 32-bit int. Altogether it is 20 bytes (8 + 8*1 + 4). On 32-bit systems sizeof is 20 bytes and everything is OK. But on the 64-bit Linux sizeof returns 24 bytes. That is, an alignment at the 64-bit border takes place.

Continue reading