delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/19/12:10:36

From: root AT 127 DOT 0 DOT 0 DOT 1 (Crewden)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Code split
Date: Mon, 19 Jul 1999 03:10:56 GMT
Organization: _
Lines: 86
Message-ID: <37929615.21843789@server>
References: <hlwk3.1012$J5 DOT 13518 AT c01read02-admin DOT service DOT talkway DOT com>
Mime-Version: 1.0
X-Trace: ruby.mint.net 932353737 7456 208.220.39.11 (19 Jul 1999 03:08:57 GMT)
X-Complaints-To: abuse AT mint DOT net
X-Newsreader: Forte Agent 1.5/32.452
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

No no no.
NEVER EVER include .C files.
This is a really really bad idea.  


Here's what you should do:

Make function prototypes for you .c files and put them in
corresponding .h files.  Include the .h file from the main.c file.

Let say you have two files.  One called utils.c  the other is called
main.c    main.c uses from of utils.c's functions.


You've got a function utils.c like this

int sum(int a, int b)
  {
  return a+b;
  }

Make the prototype in a header called utils.h

int sum(int a, int b);


Now Make your main.c like this:

#include "utils.h"

int main()
  {
  int n1=1;
  int n2=2;
  int ans;

  ans=sum(n1,n2); 

  return 0;
  }














On Mon, 19 Jul 1999 02:47:41 GMT, "marciom" <marciom AT geocities DOT com>
wrote:

+hello all,
+
+I'm developing a small MS-DOS database aplication using DJGPP,
+RHIDE (and ALLEGRO as GUI) and I've decided to put the code in
+separated files by function:
+
+- fichario.c  (main code)
+- dados.c     (data manipulation code)
+- interface.c (interface code)
+and
+- fichario.h (needed by all above!!!).
+
+In "fichario.c" I have the following initialization:
+
+#include <allegro.h>
+#include "fichario.h"
+#include "dados.c"
+#include "interfac.c"
+
+Having split the code in different files I now just can debug 
+step-by-step the code in main file "fichario.c". 
+
+How do I put it all (maybe using a Project) in a way
+that I can debug/trace code in every file?
+
+I thank you masters in advance,
+Marcio
+Fortaleza, CE, Brazil

- Raw text -


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