delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/28/15:58:53

Message-ID: <37F0EF05.B46FB474@crosswinds.net>
From: Ishpeck <ishpeck AT crosswinds DOT net>
Organization: Lunaticnologies
X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.9-19mdk i686)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie Question
References: <37F065E4 DOT 2C3B57D5 AT virtualis DOT com>
Lines: 42
NNTP-Posting-Host: 192.41.69.42
X-Trace: typ12.nn.bcandid.com 938536662 192.41.69.42 (Tue, 28 Sep 1999 12:37:42 EDT)
NNTP-Posting-Date: Tue, 28 Sep 1999 12:37:42 EDT
Date: Tue, 28 Sep 1999 10:38:29 -0600
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

It's very simple.  A header file is just a source file with the .h
extension.  When you import  header, you'll usually go like so:

#include "header.h"//Notice, it's in quotes, not <> thingies

If your header is in a different directory as your source file, go like
this.

#include "other/dir/header.h"

Voila!  It's done!

Inside your header, you might want it all within a special if statement,
just so you don't over-declare anything.  Like so

#ifndef __MY_HEADER_NAME__ //The underscores are an arbitrary detail
#define __MY_HEADER_NAME__

//Header goes in here:
//Function prototypes
//Global variables
//Constants, etc.

#endif

After that, you just treat it like a normal source file.

Alex Mendes da Costa wrote:
> 
> Hi All.
> I know a bit about C programming (i.e. the basics) and wrote a list of C
> routines that I want to be able to save seperately and then use them in
> other programs I write. I don't know how to write a header file or
> invoke the routines with it. Please Help!!
> 
> Thanks,
> Alex

-- 
Those who seek enlightenment
may turn to Ishpeck the wise.
http://come.to/ishpeck/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019