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 6577269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:36:51+00:00 2026-05-25T15:36:51+00:00

I found a method of computing the offset of struct. as follow: #define offsetOf(type

  • 0

I found a method of computing the offset of struct. as follow:

#define offsetOf(type , f)  ((int)\
 ((char *)&((struct tagName*)0)->f-(char*)(struct tagName*)0)); 

but I often write it like this:

#define offsetOf(type , f)  ((int)(&((struct tagName*)0)->f); 

The book said the subtraction of NULL pointer is to make sure it’s correct when the inner of NULL pointer is non-zero. but i think that the inner of the NULL pointer is not effect the address of the NULL Pointer.

  • 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-25T15:36:51+00:00Added an answer on May 25, 2026 at 3:36 pm

    The standard library should supply an offsetof that does exactly what you want, I would strongly recommend that you use it, as many compilers would issue a warning for the kind of code that would be required for a custom variant.

    Anyway, the subtract will take your code from the pointer domain to the domain of size_t. I would say that it’s a little bit safer.

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

Sidebar

Related Questions

I found this page describing the Muenchian method, but I think I'm applying it
In their book Digital Signal Processing Proakis & Manolakis describe a Method for computing
I've found a method on the Internet to convert RGB values to HSV values.
I added 3 optional boolean parameters to a method found within a VB6 DLL.
Has anyone found a good method of mocking out ADO.Net Data Service calls from
I am getting a Method not found: 'Boolean MyCompany.LibraryAssembly.SomeFunction(System.String)' exception/error when running a VB.NET
I was working on a demo method and found something strange(at least to me
I'm converting an application to use Java 1.5 and have found the following method:
What's the easiest method people have found to monitor memcached on Windows? One method
The only reliable method that I a have found for using a script to

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.