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

  • Home
  • SEARCH
  • 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 9286699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:29:00+00:00 2026-06-18T19:29:00+00:00

I have three files. trees.h // a bunch of typedefs and function prototypes #include

  • 0

I have three files.

trees.h
// a bunch of typedefs and function prototypes
#include <trees.c>

trees.c
// a bunch of function bodies

main.c
#include <trees.h>

This isn’t right, because every function in trees.c is giving me “undefined type” errors about the type defined in trees.h. I’ve tried every configuration I can think of – include trees.c from main and include trees.h from trees.c, include trees.c at the end of trees.h, include it at the beginning of trees.h… Every combination of includes I could think of, and each one gives a different set of errors. Sometimes it’s multiple defines, sometimes it’s undefined functions…

So how exactly does this work? What do I put in which files, and which files do I include and where?

  • 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-18T19:29:01+00:00Added an answer on June 18, 2026 at 7:29 pm

    Like this:

    trees.h
    // a bunch of typedefs and function declarations (prototypes)
    
    trees.c
    #include <trees.h>
    // a bunch of function definitions (bodies)
    
    main.c
    #include <trees.h>
    

    Explanation:

    #include is basically the same as copying the entire included file to this file (where you put the #include).

    So including trees.h in main.c allows that file to know about functions in trees.c.

    Including trees.h in trees.c allows functions lower down in trees.c to be usable and this is also where defines, etc. used in trees.c is specified.

    You also may not know about creating multiple objects and linking them, refer to Joachim Pileborg’s answer.

    The (very ugly) alternative is:

    trees.h
    // a bunch of typedefs and function declarations (prototypes)
    
    trees.c
    #include <trees.h>
    // a bunch of function definitions (bodies)
    
    main.c
    #include <trees.c>
    

    Then you just need to compile main. But for any project of a few .c files, this becomes impractical.

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

Sidebar

Related Questions

I have three files: lib.c lib.h => They should be built as a .so
I have three files: one called sql.php witch has a class db that I
I have three files in a folder 'test' one.php two.php print.html And i have
I have three files: movie.h (header); movie.cpp (implementation file); lab9.cpp (driver file using movie
After compiling some code, the compiler generates a bunch of files. I have statistics,
I have a bunch of XML files which are using prefixes but without the
I have a bunch of files (with same name, say abc.txt) strewn all over
On Ubuntu, I have a bunch of files in a tree all called 'output.txt'.
I have a bunch of unknown files in my Bazaar working tree that I
I have a program that creates a bunch of movie files. I runs as

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.