delorie.com/archives/browse.cgi | search |
From: | XkidCodeR <lil_str8_shooter AT usa DOT net> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Newbie question - want to have one function in a separate file, how do I code? |
Date: | Tue, 12 Jan 1999 15:05:58 +1100 |
Organization: | Customer of Connect.com.au Pty. Ltd. |
Lines: | 43 |
Message-ID: | <369ACA25.B1A26CBC@usa.net> |
References: | <369c3855 DOT 11709658 AT news> |
NNTP-Posting-Host: | acc4-ppp111.syd.enternet.com.au |
Mime-Version: | 1.0 |
X-Trace: | perki.connect.com.au 916113928 16042 210.8.3.111 (12 Jan 1999 04:05:28 GMT) |
X-Complaints-To: | abuse AT connect DOT com DOT au |
NNTP-Posting-Date: | 12 Jan 1999 04:05:28 GMT |
X-Mailer: | Mozilla 4.08 [en] (Win98; I) |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Stuart Hall wrote: > I can't ask this is the C groups because I am afraid that it is > compiler specific... anyway... > > I have made an implementation of gets() that is a lot safer than the > standard function - it is safer because it won't overrun an array. > > I would like to include this function in just about every program that > I write, but I don't really want to write the function prototype and > copy and paste the function into every program. Is there a method for > placing either the Object file, or the C file in a common location and > calling for it with an #include statement? > > I tried compiling the two programs together by accident (I had both of > them open at once in RHIDE), where make tried creating an aout.o file, > but I got all sorts of errors about multiple #include statements (I > use the <string.h> header in both the getsafe() program and my main > program. > > Is the method to simply create a file with just the function and its > prototype without any #include information? > > I really need to try looking at the 'info' documentation some more, > but if anyone has any additional advice, I'd be glad to hear it. > > Thanks, > Stuart > - ratboy > (don't be surprised if you email me and the response > comes back from somewhere else - iname.com is just a > forwarding service) Well here is something that you can try put the code into a header file ( a file with the .h extension) then copy the file to your include path. Then its a matter of simply including that header file into your code eg. #include <getsafe.h> then you can use it in any of your source code without putting it into every file.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |