Message-ID: <33D1C734.C2A91B6E@gapeach.com> Date: Sun, 20 Jul 1997 04:07:17 -0400 From: Jacob Martin Reply-To: jake AT gapeach DOT com MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: declaring/passing ptrs to @D arrays References: <33D10773 DOT 45C94A8D AT gapeach DOT com> <01bc94f3$a22308a0$b756dec2 AT algorithm> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: ip182.iainc.net Lines: 154 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Russ Williams wrote: > Jacob Martin wrote in article > <33D10773 DOT 45C94A8D AT gapeach DOT com>... > > how do I do this? I keep getting bad comilation stuff.... > > > > I thought I had it right, then I started the whole..."hmmm, add > another > > star?hmmm remove a star...hmmm" > > > > and I finally got it to compile( halfway) but it gives me this: > > > > E:\game>gxx test.cc -lj -lm > > e:/djgpp/tmp\ccdaaaaa(.text+0xc0):test.cc: undefined reference to > > `mapmaker(int > > *, int)' > > e:/djgpp/tmp\ccdaaaaa(.text+0x170):test.cc: undefined reference to > > `frenchtile(i > > nt *, buffer_rec *, bufinde *, int)' > > > > Here's the relevant code... > > > > void frenchtile(int *,buffer_rec *bufferptr,bufinde *btp, int); > > void mapmaker (int *,int) ; > [...] > > void frenchtile(int **mmp,buffer_rec *bufferptr,bufinde *btp,int > page) > [...] > > void mapmaker (int **mmp, int size) { > > The problem is that you're using C++ ;). If you compiled that code as > C, > the compiler would shout at you for passing int * to a function that > wants > int **. C++ allows multiple definitions for a given function, with > different parameter types, so it compiles and then tries to link to > the > mapmaker (int **,int) function, which doesn't exist... > OK, now I get this...: E:\game>gcc test.cc -lj test.cc: In function `int main()': test.cc:58: assignment to `int **' from `int *' I just can't seem to get the damn pointer procedural stuff to work: So, what's the correct way to set a pointer to the first address of mapmake, and then pass it to a function... Please fill in the blanks for me: void passit(int ___); /* pass the pointer,Do I use one or two *'s? int main() { int mapmake[100][100], __mmp; /*???????????????*/ mmp=&mapmake[0][0]; /*????????????*/ passit(int __mmp); } void passit(int __) { printf("whoopie!"); } /*this is the old code*/ void frenchtile(int *,buffer_rec *bufferptr,bufinde *btp, int); void mapmaker (int *,int) ; int main(void) { int *mmp; int mapmake[100][256]; mmp=&mapmake[0][0]; mapmaker(mmp, size); frenchtile(mmp,bufferptr,btp,page); void frenchtile(int **mmp,buffer_rec *bufferptr,bufinde *btp,int page) { int loop; int index; int x,y=0; for (loop=0;loop< 256;loop++) { if ((loop%17)==0) { y=(32*(loop/17)); } if (x==544) x=0; if (*(*(mmp+page)+loop)!=NULL) { index=*(*(mmp+page)+loop); screen_blit_buff_to(x,y,bufferptr,btp[index].bx1,btp[index].by(THIS PART I couldn't paste, but it don't matter); } x+=32; } } void mapmaker (int **mmp, int size) { char width[100]; int loop,count,loopa,first,second; /*SET LAND AREA*/ for (loop=0;loop < 100; loop ++) { width[loop]=rand() % 2; } /*REMOVE SIZE AMOUNT OF LAND*/ for (loop=0;loop< 98;loop=loop+size) { width[loop]=0; } /*MAKE EACH SCREEN WITH LAND FLAG*/ for (loop=0;loop<100;loop++) { if (width[loop]==1) { first=1 + rand() % 8; second=10 + rand() % 17; while (count < 10) { for (loopa=(10*count)+first;loopa <= (10 * count)+second;loopa++) mmp[loop][loopa]=1; count ++; } /*END WHILE*/ }/*end IF*/ }/* end for*/ } > [...] > > Thanks... > > > No problem. > > --- > Russ