• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

nevermind

Where did you dig this up from?

My interpretation:

It looks as if the define is trying to cast a NULL value (i.e. the value 0) to a pointer of type z to access its member variable w. This would certainly cause an Access Violation fault no matter what z and w is....


🙂atwl
 
First; Ok, fess up time, whats going on here? Is this someones extra credit on their homework? This EXACT question was asked in this thread earlier today (and that poster also cross posted here in OT).

Second; There is a forum called 'applications, PROGRAMMING, and games'. OffTopic is not for programming questions.

Third; Fess up, the chance that both of you randomly asked the same question about the same obscure technique to get the integer offset of a structure member approaches zero quite quickly.

Bill
 
It looks as if the define is trying to cast a NULL value (i.e. the value 0) to a pointer of type z to access its member variable w. This would certainly cause an Access Violation fault no matter what z and w is....

Actually it wouldn't, it returns the count (in bytes) to the structure element. It never attempts a write or even a read at that location.

Bill
 
To tell you the truth, no. I've graduated and am not currently doing any kind of C/C++ work.

Then come on and share, why the same weird question from two users on the same day? I can't believe that was a coincidence... The only thing changed in the two threads was the macro name.

Bill
 
Actually, being a C/C++ programmer, I'd like to understand the logic behind that macro. I couldn't find it anywhere, so if my memory serves me correct, it looks like:

#define TEST(z, w) int(&(((z*)0)->w))

So...... how does it work? My primitive mind 🙂D) immediately drew my attention to the ((z*)0)->w part, which gave me my original conclusion.


🙂atwl
 
Back
Top