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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:27:19+00:00 2026-05-15T22:27:19+00:00

while I am creating a c++ header file, I declare the header file like;

  • 0

while I am creating a c++ header file, I declare the header file like;

/*--- Pencere.h ---*/
#ifndef PENCERE_H
#define PENCERE_H

I want to learn that why do I need to write underline.

  • 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-15T22:27:19+00:00Added an answer on May 15, 2026 at 10:27 pm

    You don’t need to use the underline, it’s just a convention to separate the header name and extension. You cannot use the literal . since that’s not valid in an identifier so you replace it with an underscore which is valid.

    The reason you actually do it is as an include guard. The entire contents of the file are something like:

    #ifndef PENCERE_H
        #define PENCERE_H
        // Your stuff goes here.
    #endif
    

    so that, if you accidentally include it twice:

    #include "pencere.h"
    #include "pencere.h"
    

    you won’t get everything in it duplicated. The double inclusions are normally more subtle than that – for example, you may include pax.h and diablo.h in your code and pax.h also includes diablo.h for its purposes:

    main.c:
        #include "pax.h"
        #include "diablo.h"
        // Other stuff
    
    pax.h:
        #ifndef PAX_H
            #define PAX_H
            #include "diablo.h"
            // Other stuff
        #endif
    
    diablo.h:
        #ifndef DIABLO_H
            #define DIABLO_H
            typedef int mytype;
        #endif
    

    In this case, if the include guards weren’t there you would try to compile the line typedef int mytype; twice in your program. Once for main.c -> pax.h -> diablo.h and again for main.c -> diablo.h.

    With the include guards, the pre-processor symbol DIABLO_H is defined when main.c includes diablo.h so the #define and typedef are not processed.

    This particular mapping of header files to #define names breaks down in the situation where you have dir1/pax.h and dir2/pax.h since they would both use PAX_H. In that case, you can use a scheme like DIR1_PAX_H and DIR2_PAX_H to solve the problem.

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

Sidebar

Related Questions

I'd like to learn how to grab information from a FITS file header and
While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that
I ran into some trouble while creating a C-Extension for ruby that got me
I am creating XML using a while loop, but now I need to prepend
while creating a library that will be used on several projects, I encountered an
I am creating an imap client. I want to parse body and header of
Using vim 7.3.1, ubuntu 11.10 I am creating a tag file using ctags while
While creating the setup for VB.net application I am getting the following warning: Warning
while creating a thread in java, there is two ways such as Extending threads
While creating a command line tool (Mac OS X) project in XCode, one has

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.