Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:48:31+00:00 2026-05-27T09:48:31+00:00

I am reading Essential COM and encountered a macro ‘BASE_OFFSET’ from chapter 2 of

  • 0

I am reading Essential COM and encountered a macro ‘BASE_OFFSET’ from chapter 2 of the book and I don’t really understand its syntax or why it’s done that way.

#define BASE_OFFSET(ClassName, BaseName) \
(DWORD_PTR(static_cast<BaseName*>(reinterpret_cast<ClassName*>(0x10000000))) - 0x10000000)

Can anyone explain this macro and how we use this? In fact, the book uses this macro but since I don’t really understand it, I don’t see the practical usage of it. Thank you very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:48:32+00:00Added an answer on May 27, 2026 at 9:48 am

    The macro makes up a dummy pointer to ClassName with the reinterpret_cast and then casts it to the BaseName with the static_cast.

    In the presence of multiple inheritance, the address of a base class subobject is not always the same as the address of the object. This possibly-different-address is subtracted from the original dummy address, to obtain the offset of the BaseName subobject in a ClassName object. It’s similar to offsetof, but for base class subobjects instead of members.

    Diagram showing an example

    This is only useful if you’re doing some nasty low-level stuff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading Essential COM , it is a very good book, very instructive
I was reading the Essential C# 3.0 book and am wondering if this is
I am reading a single data item from a UDP port. It's essential that
reading excel files from C# working well in 32 bit version server. It is
I was reading an article here: http://javascriptweblog.wordpress.com/2010/03/16/five-ways-to-create-objects/ It tells about five ways of creating
I am a beginner for Twisted. Recently, I am reading the book Twisted Network
I've been playing around with prototypal inheritance after reading http://javascript.crockford.com/prototypal.html and having a bit
I was reading up on http://pages.github.com/ and one thing caught my eye: If you
Can I use Delphi to program to the Java Native Interface ? From reading
Reading this question I found this as (note the quotation marks) code to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.