Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POINTER_32 - what is it, and why?

I have just been given the task of updating a legacy application from 32-bit to 64-bit. While reviewing the extent of the task, I discovered the following definition immediately before the inclusion of external (eg. platform) headers:

#define POINTER_32

I cannot find what uses this definition or what effect it has, but it looks like the kind of thing that will be directly relevant to my task!

What is it for? What uses it? Will it be safe to remove it immediately (I presume it will be necessary to remove it in the long run)?

This is using MS VC++ 2008, soon to be 2010.

like image 647
Andy Patrick Avatar asked Aug 10 '10 10:08

Andy Patrick


2 Answers

This is a macro that's normally declared in a Windows SDK header, BaseTsd.h header file. When compiling in 32-bit mode, it is defined as you showed. When compiling in 64-bit mode it is defined as

 #define POINTER_32 __ptr32

which is an MSVC compiler extension to declare 32-bit pointers in a 64-bit code model. There's also a 64-bit flavor for 32-bit code:

 #define POINTER_64 __ptr64

You'd use it if you write a 64-bit program and need to interop with structures that are used by 32-bit code in another process. For example:

typedef struct _SCSI_PASS_THROUGH_DIRECT32 {
    USHORT Length;
    UCHAR ScsiStatus;
    UCHAR PathId;
    UCHAR TargetId;
    UCHAR Lun;
    UCHAR CdbLength;
    UCHAR SenseInfoLength;
    UCHAR DataIn;
    ULONG DataTransferLength;
    ULONG TimeOutValue;
    VOID * POINTER_32 DataBuffer;      // <== here
    ULONG SenseInfoOffset;
    UCHAR Cdb[16];
}SCSI_PASS_THROUGH_DIRECT32, *PSCSI_PASS_THROUGH_DIRECT32;
like image 91
Hans Passant Avatar answered Nov 14 '22 23:11

Hans Passant


Used to get around the Warning C4244 . Provides a 32-bit pointer in both 32-bit and 64-bit models

like image 29
DumbCoder Avatar answered Nov 14 '22 21:11

DumbCoder