delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/26/00:23:17

From: Adam Christopher Lawrence <guruman AT interlog DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Headers, multiple .C files, and Allegro BITMAP structures.
Date: Fri, 25 Jul 1997 13:36:19 -0400
Organization: InterLog Internet Services
Lines: 75
Message-ID: <33D8E413.16741DD1@interlog.com>
NNTP-Posting-Host: ip226-23.cc.interlog.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

    Here's a funky problem.

    I'm working on a program that has numerous routines that draw to a
Allegro BITMAP structure. As it presently stands, the source is one huge
messy file, and all of the variables needed for each draw routine are
global in scope. For example

    /* - myprog.c */

   /* global declarations */

    BITMAP *bmp;
    int max_xres, max_yres, preiter, iter;
    double xmin, xmax, ymin, ymax;

    // more globals, code and stuff here...

   void myDrawRoutine() {
        // misc drawing stuff
        putpixel(bmp, x, y, color);
        // blah blah
        blit(bmp, screen,0, 0,  max_xres, max_yres);
    }

    You get the idea. Anyhow, I got the idea of encapsulating the eight
separate drawing routines into a separate module, and passing all of the
required information to them - eliminating the need for as many globals
and adding to this 'independance' thing.

    So, I made a header file containing the needed prototypes...

    /* iterator.h */

    void myDrawRoutine(BITMAP *bmp, int preiter, int iter, int max_xres,
int max_yres, double xmin, double xmax, double ymin, double ymax); //
prototype

 /* end iterator.h */

    ... and the separate module containing the draw routines...

 /* iterator.c */

#include "iterator.h"

 void myDrawRoutine(BITMAP *bmp, int preiter, int iter, int max_xres,
int max_yres, double xmin, double xmax, double ymin, double ymax) {
            // misc drawing stuff
            putpixel(bmp, x, y, color);
            // blah blah
            blit(bmp, screen,0, 0,  max_xres, max_yres);
    }

    ... and a reference from the rest of the code.

/* mainprog.c */

    #include "allegro.h"
    #include "iterator.h"

    //blah blah

    void main() {
    }

    I code using Rhide, so I added "iterator.c" to the project. In the
project window, I had "iterator.c" and "myprog.c".

    To my knowledge, this ought to work. The problem is, the compiler
craps out on the iterator.h file, stating that it has no hairy idea what
the heck a BITMAP is. Shouldn't the 'allegro.h' from the main file take
care of that? Am I making a stupid beginner mistake like the stupid
beginner that I am? Any clairification that could be provided would be
greatly appreciated.

- Raw text -


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