Posted by ADnoctum on 1999-11-01
I'm experimenting a very strange problem with DJGPPv2. I have a simple mode
13h library(another) splited in tree files:
/* vga.h */
#ifndef VGA_H
#define VGA_H
#define maxx 320
#define maxy 200
// special types that i need
// functions prototypes
#endif
/* vga.cc */
#include "vga.h"
// implementation of the functions declared in vga.h
/* vgatest.cc */
#include "vga.h"
int main()
{
// stuff to draw a horizontal line
}
All that work well, but I don't like #defines, so I change it to "const
unsigned", tested and worked.
Then, to alow to use 256c modes others than 13h I remove the const keyword
and worked...
Now I add a new function(line) to draw(you guess =) a line. Here is the
code:
void line( unsigned x1, unsigned y1, unsigned x2, unsigned y2, char color,
linetype lt = lSOLID )
{
char sgndistx1, sgndisty1, sgndistx2, sgndisty2;
int counter2, distx, disty, absdistx, absdisty;
unsigned int counter;
char *tmp;
distx = x2 - x1;
disty = y2 - y1;
if( distx<0 )
sgndistx1 = -1;
else
if( distx>0 )
sgndistx1 = 1;
else
sgndistx1 = 0;
if( disty<0 )
sgndisty1 = -1;
else
if( disty>0 )
sgndisty1 = 1;
else
sgndisty1 = 0;
absdistx = distx;
if( absdistx<0 )
absdistx *= -1;
absdisty = disty;
if( absdisty<0 )
absdisty *= -1;
if( absdistx<=absdisty ) {
sgndistx2 = 0;
sgndisty2 = sgndisty1;
counter2 = absdistx;
absdistx = absdisty;
absdisty = counter2;
} else {
sgndistx2 = sgndistx1;
sgndisty2 = 0;
}
counter2 = absdistx >> 1;
for( counter = 0; counter != absdistx; counter++ ) {
if( (x1<maxx) && (y1<maxy) ) {
tmp = (char *)vgaaddress + ( y1 * maxx ) + x1;
*tmp = color;
}
counter2 += absdisty;
if( counter2>=absdistx ) {
counter2 -= absdistx;
x1 += sgndistx1;
y1 += sgndisty1;
} else {
x1 += sgndistx2;
y1 += sgndisty2;
}
}
}
And when I compile it, gcc giveme this errors:
Error: vgatest.o(.data+0x0):vgatest.cc: multiple definition of `maxx'
Error: vga.o(.data+0x0):vga.cc: first defined here
Error: vgatest.o(.data+0x4):vgatest.cc: multiple definition of `maxy'
Error: vga.o(.data+0x4):vga.cc: first defined here
I don't know were is the error here...
thanks
PD: excuseme if the message was too long.
ADnoctum
adnoctum@xxxxxxxxxx.xxx
Previous post | Next post | Timeline | Home