header page 3 - Dave's Blog

Search
My timeline on Mastodon

An Exploration of Dynamic Documents

2007 Sep 4, 6:57Netscape's documentation on the non-standard HTTP refresh header.PermalinkCommentsrefresh http http-header netscape reference

Wp64 Issues

2007 Aug 6, 3:43Miladin told me about the Visual Studio compiler's promising option Wp64 that finds 64bit portability issues when compiling in 32bit. If, for instance, you cast from a (long*) to a (long) you get a W4 warning. However, the #defines are still set for 32bit builds. This means that other parts of the code can make assumptions based on the #defines that are valid on 32bit but generate 64bit errors or warnings.

For instance, in winuser.h the public published Windows header file there's the following:
...
#ifdef _WIN64
...
WINUSERAPI
LONG_PTR
WINAPI
SetWindowLongPtrA(
    __in HWND hWnd,
    __in int nIndex,
    __in LONG_PTR dwNewLong);
...
#else  /* _WIN64 */
...
#define SetWindowLongPtrA   SetWindowLongA
...
#endif /* _WIN64 */
...
In 64bit everything's normal but in 32bit SetWindowLongPtrA is #defined to SetWindowLongA which takes a LONG rather than a LONG_PTR. So take the following code snippet:
...
LONG_PTR inputValue = 0;
LONG_PTR error = SetWindowLongPtrA(hWnd, nIndex, inputValue);
...
This looks fine but generates warnings with the Wp64 flag.

In 64 bit, p is cast to (LONG_PTR) and that's great because we're actually calling SetWindowLongPtrA which takes a LONG_PTR. In 32 bit, p is cast to (LONG_PTR) which is then implicitly cast to (LONG) because we're actually calling SetWindowLongA. LONG and LONG_PTR are the same size in 32bit which is fine but if you turn on the Wp64 flag there's a W4 warning because of the implicit cast from a larger size to a smaller size if you were to compile for 64bit. So even though doing a 32bit or 64bit compile would have worked just fine, if you turn on the Wp64 flag for 32bit you'd get an error here.

It looks like I'm the most recent in a list of people to notice this issue. Well I investigated this so... I'm blogging about it too!PermalinkCommentswp64 technical 64bit compiler c++ visual-studio setwindowlongptra

IANA | Permanent Message Header Field Registry

2007 Apr 2, 1:31The IANAs list of headers for HTTP and mail.PermalinkCommentsemail http iana internet reference registry rfc standard standards

Instance Digests in HTTP

2006 Aug 4, 11:13PermalinkCommentsrfc digest sha-1 reference ietf internet md5 hash http http-header

Fiddler HTTP Debugger - Debugging Essentials

2006 Apr 7, 4:59Good tools for debugging IE problems.PermalinkCommentseric-lawrence fiddler tool tools debug development http http-header ie ie7 web internet

PEP - an Extension Mechanism for HTTP

2006 Apr 6, 12:02PermalinkCommentshttp w3c http-header pep internet reference

Web Browser User-Agent Information - Change IE's User Agent

2006 Feb 22, 2:28PermalinkCommentseric-lawrence fiddler http user-agent ie internet http-header

RFC 4229 - Registered HTTP Header Fields

2006 Feb 17, 12:31PermalinkCommentshttp internet reference http-header rfc specification

HTTP State Management Mechanism

2005 Mar 28, 10:47This document specifies a way to create a stateful session with Hypertext Transfer Protocol (HTTP) requests and responses. It describes three new headers, Cookie, Cookie2, and Set-Cookie2, which carry state information between participating origPermalinkCommentscookie reference rfc development internet http
Older EntriesNewer Entries Creative Commons License Some rights reserved.