From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: .H Files?!?!?!??! Date: Wed, 29 Apr 1998 19:19:23 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 39 Message-ID: <3547B57B.2754@cs.com> References: <354b8dfe DOT 5794537 AT news DOT concentric DOT net> NNTP-Posting-Host: ppp123.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Sanchez the Skiing Communist Cactus wrote: > > Sorry if this quesiton is asked frequently, or if the answer is > painfully obvious... but please answer it anyway. I recommend using a C tutorial of some sort, whether in a book or in a class. The proper use of header files is a fairly detailed topic that's not easy to discuss in a simple email or news post. It's also not DJGPP-specific. > Ok.... from what I am able to figure out... A C/C++ *.h file > contains macro/constant Definitions, and Function PROTOTYPES.... my > only question is: If I were to create a .h file for my own use, where > do I put the actual function Body? Header files declare code that is defined in other source files (or in a library, which is basically the same thing). Therefore, you put the function body in another source file which must also be compiled along with your program. For example, if I have a two-module program: main.c and driver.c, and there are some functions in driver.c that main.c needs to use, I would probably write a header file named driver.h containing all the prototypes needed by main.c. Then, I #include "driver.h" in both source files, compile each to an object module, and link them together to produce the final executable: gcc -Wall -O -g -c main.c gcc -Wall -O -g -c driver.c gcc -o program.exe main.o driver.o This task can be greatly simplified by using a project management tool like Make or RHIDE, particularly for large projects. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | ICQ UIN#: 7406319 | http://www.cs.com/fighteer/ | | ObJoke: If Bill Gates were a robber, not only would he | | shoot you, but he'd send you a bill for the bullets. | ---------------------------------------------------------------------