| delorie.com/archives/browse.cgi | search |
| From: | Colin Walsh <cwalsh AT nf DOT sympatico DOT ca> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Creating Class Libraries |
| Date: | Tue, 19 Aug 1997 16:35:26 -0230 |
| Organization: | Colossal Software |
| Lines: | 82 |
| Message-ID: | <33F9EE76.7A91@nf.sympatico.ca> |
| Reply-To: | cwalsh AT nf DOT sympatico DOT ca |
| NNTP-Posting-Host: | 204.101.95.15 |
| Mime-Version: | 1.0 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
I have tried recently to create libraries supporting all of the
filetypes that I keep creating for my various projects, but a problem
has come up. I want the libs to use classes, but they wont compile
properly.
Here is the source that loads .CGR (Colossal GRaphics)
#include <fstream.h>
#include <malloc.h>
#include <grx20.h>
class cgrfile{
protected:
unsigned char *cgrdata;
long w,h;
public:
cgrfile()
{
cgrdata=(unsigned char *)malloc(0);
w=0;
h=0;
}
void cgrload(char *filename,int palswitch)
{
unsigned char bit;
unsigned char RGB[3];
fstream cgr(filename,ios::in|ios::binary);
cgr.read((char *)&w,sizeof(long));
cgr.read((char *)&h,sizeof(long));
cgrdata=(unsigned char *)realloc((void
*)cgrdata,w*h);
if(palswitch==0)//dont load the palette
{
for(int x=0;x<256;x++)
{
cgr.read(RGB,3);
}
}
if(palswitch==1)//load the palette
{
for(int x=0;x<256;x++)
{
cgr.read(RGB,3);
GrSetColor(x,RGB[0],RGB[1],RGB[2]);
}
}
for(long x=0;x<w*h;x++)
{
cgr.get(bit);
cgrdata[x]=bit;
}
}
void display()
{
long pos=0;
for(long x=0;x<w;x++)
{
for(long y=0;y<h;x++)
{
GrPlot(x,(h-1)-y,cgrdata[pos]);
pos++;
}
}
}
};
And this is the batch (too bothersome to create make files w/ dos
edit(not proper Tab)) file:
gcc -c cgr.cpp -o cgr.o
ar rvs libcgr.a cgr.o
copy libcgr.a \proglang\djgpp\lib
When the COFF file is created, it is waaay too small (365 bytes) to have
all this code.
I was wondering if anyone can tell me what needs to be changed so it
compiles properly, and yes...
I have read the FAQ on compiling libraries, but there is no info on how
you compile a class library.
Thanks for any help,
Colin Walsh
President/CEO/Dictator for life :), Colossal Software
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |