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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:29:16+00:00 2026-05-30T02:29:16+00:00

I’m a bit confused about object files that contain headers. I don’t see how

  • 0

I’m a bit confused about object files that contain headers. I don’t see how header guards can protect you if they’re included in multiple object files.

For instance:

main.o <- main.cpp class.h
class.o <- class.cpp class.h
main.exe <- main.o class.o

Wouldn’t each object file contain class.h thereby making the executable have two copies of it?

  • 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-30T02:29:18+00:00Added an answer on May 30, 2026 at 2:29 am

    Object files don’t contain headers; they contain the output of the
    compiler. But the point you raise is valid: anything in the header may
    be duplicated several times in the final code. Roughly speaking, we can
    distinguish two categories:

    1. Declarations that don’t create anything which might end up in the
      compiler output: things like typedef’s, or for that matter, templates
      and class definitions. The standard allows duplicate definitions,
      provided that they’re all “identical”.

    2. Declarations that you’re not allowed to duplicate, and which
      shouldn’t be in a header. Things like variables and functions.

    In practice, it’s a bit more complex, a template may be instantiated
    over the same type in several different sources, and the instantiation
    of a template may be a function. Or the compiler may fail to inline an
    inline function. The usual way of dealing with this is for the compiler
    to generate the function in each translation unit, and for the linker to
    throw out the duplicates. (In fact, most linkers don’t check whether
    they really are duplicates. They just throw out all but one, chosen
    more or less randomly.)

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string

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.