CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Macro question

Threaded View

  1. #1
    Join Date
    Apr 2002
    Location
    Kansas City, MO
    Posts
    34

    Macro question

    I'm in the middle of dissecting a program, and I've run across a weird macro... I can't seem to figure out what it does:

    MACRO (z,w) ( (int) ( &(((z*)0)->w) )

    I think w is a member variable of a class or structure.
    That means the ((z*)0) has to be a pointer to a class or structure... but how's it work? That's not a dereference, since things are dereferenced with the '*' before the variable name. And why the '0'? This has got to be the weirdest piece of C code I've ever seen.
    I know it has to return an int, since that's the final cast. Also, I know it's an address location, because of the &. But what does the ((z*)0) do? Ohh, I'm so confused. C masters, please help!

    My guess is that z would be some class type, and that the "&(((z*)0)->w)" is the address of the declaration of w in memory, if that's possible. That really doesn't seem right though!
    Last edited by Riskbreaker; February 23rd, 2003 at 05:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured