Re: [NtDev] Re: Silly question on IA64

antognini@us.ibm.com said:

Sorry, I disagree with your assertion that only a pointer variable
should hold a pointer. I am continually doing pointer arithmetic, and
I have to cast a pointer into what works, typically a ULONG.

Why? Arithmetic on pointers is well defined in C.

And if you argue that you want per-byte resolution, then cast your
pointer into an ``unsigned char*‘’ instead of an unsigned long. There
are types available within the language to portably to what you want.

antognini@us.ibm.com said:

Interestingly, the macro CONTAINING_RECORD64 does arithmetic on
ULONGLONG, which is not a pointer type. You may say Microsoft ought to
have defined a ULONGLONG_PTR type to kept things pure, but I feel
doing so or not doing so is a matter of taste.

Perhaps I’m letting my bias show here, but I can’t imagine using MS
code as a model of good programming style. At least not the examples
available to us outsiders.

Steve Williams “The woods are lovely, dark and deep.
xxxxx@icarus.com But I have promises to keep,
xxxxx@picturel.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep.”


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

This is not a rhetorical question, I really don’t know the answer, although
I have my suspicions of what the answer should be…

What is the difference between casting to a ULONG, and casting to a PVOID?
If you ++ either one, they both increment by one. If you add 0x10, they
will both advance by 16. So why is ULONG, which isn’t 100% safe, preferred
over PVOID, which is? Are there issues using PVOID that don’t show up using
ULONG?

Thanks,

Phil

-----Original Message-----
From: James Antognini [mailto:antognini@us.ibm.com]
Sent: Wednesday, June 06, 2001 8:08 AM
To: NT Developers Interest List
Subject: [ntdev] Re: [NtDev] Re: Silly question on IA64

Sorry, I disagree with your assertion that only a pointer variable
should hold a pointer. I am continually doing pointer arithmetic, and I
have to cast a pointer into what works, typically a ULONG.
Interestingly, the macro CONTAINING_RECORD64 does arithmetic on
ULONGLONG, which is not a pointer type. You may say Microsoft ought to
have defined a ULONGLONG_PTR type to kept things pure, but I feel doing
so or not doing so is a matter of taste.

That said, in product code where I used ULONG for pointer values, I
always appended a comment that the technique was not
64-bit-address-safe. Matters of taste aside, it’s wise to leave a
warning.


James Antognini
IBM Watson Research


You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Doesn’t PVOID present a problem in that its increment value is
undefined? Perhaps you meant PCHAR (or PBYTE), which does increment by
1.


James Antognini
IBM Watson Research


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

To answer your question substantively, I’ve run into cases where PCHAR
didn’t work the way I needed. I’ll try to find some of them.


James Antognini
IBM Watson Research


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com