Message-ID: <37F16793.4D98B7CE@virtualis.com> Date: Wed, 29 Sep 1999 11:12:51 +1000 From: Alex Mendes da Costa X-Mailer: Mozilla 4.51 [en] (Win98; I) 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> <37F0EF05 DOT B46FB474 AT crosswinds DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: a4-p29.syd.fl.net.au X-Trace: 29 Sep 1999 11:16:18 +1000, a4-p29.syd.fl.net.au Organization: Customer of First Link Internet Services, Sydney, Australia Lines: 58 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Okay, so now I have a header file with my routines declared and globals and stuff called "subs.h" and I have a c program containing all these subs called "subs.c" and I have a program called "prog.c" which contains the line '#include "subs.h"'. I try to compile this using GCC (ie gcc prog.c -o prog.exe) and I get error messages for all my subs which say: c:/djgpp/tmp\cccqmssf(.text+0x123):prog.c:undefined referance to 'mysub' or something similar. I know I'm probably doing something really dumb but I can't figure it out! Thanks, Alex Ishpeck wrote: > > 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/