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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:00:25+00:00 2026-06-01T13:00:25+00:00

Say you have 100s of source files (.c or .cpp) files, and you want

  • 0

Say you have 100s of source files (.c or .cpp) files, and you want to include some definitions, function/variable declarations in each of them. Normally in C/C++, you use header files for that purpose. But in this case you need to put #include “header.h” in each source file.

Now my question is, is there a way to include one header for all the files without putting #include “header.h” in each of the file, because it will be very tiresome to write #include “header.h” for 100s of source files.

  • 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-06-01T13:00:26+00:00Added an answer on June 1, 2026 at 1:00 pm

    You can use the -include flag for clang or GCC. From the man page:

    -include file

    Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor’s working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.

    If multiple -include options are given, the files are included in the order they appear on the command line.

    Example:

    clang -include header.h -c file1.c
    clang -include header.h -c file2.c
    clang -include header.h -c file3.c
    clang -o app file1.o file2.o file3.o
    

    MSVC has the /FI flag, which is similar.

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

Sidebar

Related Questions

I have two folders (say Source and Working). Now within these, there are 100s
Say I have a Telerik MVC Grid, AJAX bound and I want to put
Say I have a byte array with 100,000 bytes in it. I want to
Say I have a bash script file config.sh . It's meant to be source'd
Let's say have a string... String myString = my*big*string*needs*parsing; All I want is to
Say I have MyClass with 100s of fields. If I use an object of
I have some data in simplejson format in txt files, which I read using:
Say have a linear model LM that I want a qq plot of the
Say we have the following simple data-frame of date-value pairs, where some dates are
Say I have files File_A , File_B and File_C . I edit File_A and

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.