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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:46:15+00:00 2026-05-26T04:46:15+00:00

I am wondering why C++ compilers don’t generate header guards automatically for headers? //

  • 0

I am wondering why C++ compilers don’t generate header guards automatically for headers?

// Why do I have to write this for every .hpp file I create?!!
#ifndef myheader_hpp__
#define myheader_hpp__
// ...
#endif

I haven’t met a situation where they aren’t needed when I write my headers. I can’t see a real use-case of the opposite behavior, but I would be glad to see one. Is there a technical difficulty or is it just history?!

  • 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-26T04:46:16+00:00Added an answer on May 26, 2026 at 4:46 am

    There are some preprocessor tricks that require the same header included multiple times into the same compilation unit. Another reference.

    Besides that, most compilers do allow you to shorten all of that down to:

    #pragma once
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Studying compilers course, I am left wondering why use registers at all. It is
I'm new to the VxWorks environment, I'm wondering what C and C++ compilers are
I am just wondering if these code blocks gets compiled into .dll I don't
This may boil down to opinion: I am wondering if project files (the files
this code doesn't compile. I'm wondering what I am doing wrong: private static Importable
I'm working on OKI 431 microcontroller. This is 8-bit microcontroller. We don't like to
I should probably know this already, but I'm not sure and I don't see
I'm wondering why I need to declare a default constructor in this case. For
Wondering if someone can answer something that has stumped me. I have a Timer
In a prism application I have a module definition like this: [Module(ModuleName = TestModule,

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.