delorie.com/archives/browse.cgi | search |
From: | "Stefan Viljoen" <Stefan_Viljoen AT excite DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Making header file - Newbie question |
Date: | Thu, 4 Jan 2001 23:30:39 +0200 |
Organization: | The South African Internet Exchange |
Lines: | 76 |
Message-ID: | <932pof$n49$1@ctb-nnrp2.saix.net> |
References: | <3A53AA94 DOT 911 AT vic DOT ozland DOT net DOT au> |
NNTP-Posting-Host: | rsb53-01-p189.gt.saix.net |
X-Trace: | ctb-nnrp2.saix.net 978643535 23689 155.239.84.189 (4 Jan 2001 21:25:35 GMT) |
X-Complaints-To: | abuse AT saix DOT net |
NNTP-Posting-Date: | 4 Jan 2001 21:25:35 GMT |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300 |
X-Mimeole: | Produced By Microsoft MimeOLE V5.00.2314.1300 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
John Casey <jgcasey AT vic DOT ozland DOT net DOT au> wrote in message news:3A53AA94 DOT 911 AT vic DOT ozland DOT net DOT au... > Hi, > > I am new to djgpp (<week) although I have dabbled in C and have > written little assembler programs. My problem is how to save the > standard functions that I call from main() in a header file so I > can just inlude them at the beginning without having to scroll > through them all to get to the latest segment I am working on. > > I have scanned as much documentation as I could until my head ached > but couldn't find anything that actually explained how to do this. > > Any pointers in the right direction would be appreciated :) > > -- John Casey Just open a different file in your text edit - put stuff in there like this: Say you have a function sayhello() that is like this #include <stdio.h> #include <conio.h> void sayhello() { printf("Sayhello!\n"); } int main(void) { sayhello(); exit(0); } change that to #include <stdio.h> #include <conio.h> #include "sayhello.h" int main(void) { sayhello(); exit(0); } and create a fille called "sayhello.h": extern void sayhello(); also create a file called "sayhello.c" containing: void sayhello() { printf("Sayhello!\n"); } then link it in at compile time so the compiler can find the code. Take a look at any of the assembly programs at http://home.intekom.com/rylan/prog.html for more detailed and working implementations of how to use very simple .h files. Regards, Stefan Viljoen F/EMS Dispatcher Potchefstroom F/EMS South Africa http://home.intekom.com/rylan/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |