Jump to content

error: conflicting types for, pointers?


jonhhy
 Share

Recommended Posts

In this file appear this error in the gcc compiler.

The error appear in fuction implementation: int paint_pixel(unsigned short x, unsigned short y, unsigned long color)

Neste ficheiro aparece um erro no compilador gcc.

Ou seja na implementação da função: int paint_pixel(unsigned short x, unsigned short , unsigned long color)

Ou seja no terminal aparece esta mensagem:

$ make
compile src/video_gr.o
video_gr.c: In function 'vg_init':
video_gr.c:33: warning: return makes pointer from integer without a cast
video_gr.c: At top level:
video_gr.c:98: error: conflicting types for 'paint_pixel'
video_gr.c:98: note: an argument type that has a default promotion can't match an empty parameter name list declaration
video_gr.c:70: note: previous implicit declaration of 'paint_pixel' was here
*** Error code 1
Stop.
make: stopped in /home/lcom/lcom1516-t2g01/proj/src
$`
talvez o tipo definido para o parâmetro color não seja o mesmo que esteja a ser declarado (usa pointers...) ??

Obrigado pelo vossa ajuda e tempo

#include <minix/syslib.h>
#include <minix/drivers.h>
#include <machine/int86.h>
#include <sys/mman.h>
#include <sys/types.h>
#include "math.h"
#include "vbe.h"
#include "i8254.h"
#include "video_gr.h"
/* Private global variables */
static char *video_mem; /* Process address to which VRAM is mapped */
static unsigned h_res; /* Horizontal screen resolution in pixels */
static unsigned v_res; /* Vertical screen resolution in pixels */
static unsigned bits_per_pixel; /* Number of VRAM bits per pixel */
int paint_pixel(unsigned short x, unsigned short y, unsigned long color);
void *vg_init(unsigned short mode) {
struct reg86u reg;
struct mem_range mem;
int i;
reg.u.w.ax = 0x4F02; // VBE call, function 02 -- set VBE mode
reg.u.w.bx = 1 << 14 | mode; // set bit 14: linear framebuffer
reg.u.b.intno = 0x10;
if (sys_int86((r)) != OK) {
printf("set_vbe_mode: sys_int86() failed \n");
return 1;
}
vbe_mode_info_t vbe;
vbe_get_mode_info(mode, &vbe);
h_res = vbe.XResolution;
v_res = vbe.YResolution;
bits_per_pixel = vbe.BitsPerPixel;
mem.mr_base = vbe.PhysBasePtr;
mem.mr_limit = mem.mr_base
+ (vbe.XResolution * vbe.YResolution * vbe.BitsPerPixel / 8);
if (OK != (i = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mem)))
panic("vg_init: sys_privctl (ADD_MEM) failed: %d\n", reg);
/* Map memory */
video_mem = vm_map_phys(SELF, (void *) mem.mr_base,
(vbe.XResolution * vbe.YResolution * vbe.BitsPerPixel / 8));
if (video_mem == MAP_FAILED) {
panic("vg_init couldn't map video memory");
return NULL;
}
return (void *) video_mem;
}
int vg_fill(unsigned long color)
{
unsigned int short x = 0, y = 0,i=0;
while (y <= h_res) {
for (i = x; i < v_res; i++) {
if (paint_pixel(i, y, color) == 1) {
vg_exit();
return 1;
}
}
y++;
}
return 0;
}
int vg_exit() {
struct reg86u reg86;
reg86.u.b.intno = 0x10; /* BIOS video services */
reg86.u.b.ah = 0x00; /* Set Video Mode function */
reg86.u.b.al = 0x03; /* 80x25 text mode*/
if (sys_int86(&reg86) != OK) {
printf("\tvg_exit(): sys_int86() failed \n");
return 1;
} else
return 0;
}
void *get_address() {
return video_mem;
}
int paint_pixel(unsigned short x, unsigned short y, unsigned long color) {

char *ptr;
ptr = video_mem;
ptr += (h_res * y + x) * bits_per_pixel / 8;
*ptr = color;
return 0;
}
int draw_square(unsigned short x, unsigned short y, unsigned short size,
unsigned long color) {
unsigned short x_max = x + size;
unsigned short y_max = y + size;
int xi = x;
int i = 0;
while (y <= y_max) {
for (i = x; i < x_max; i++) {
if (paint_pixel(i, y, color) == 1) {
vg_exit();
return 1;
}
}
y++;
}
}
void swap(unsigned short* a, unsigned short* b) {
int t = *a;
*a = *b;
*b = t;
}
int draw_line(unsigned short xi, unsigned short yi, unsigned short xf,
unsigned short yf, unsigned long color) {
//Draw line based in Bresenham's line algorithm
unsigned short dx, dy;
int d, incry, incre, incrne, slopegt1 = 0;
dx = abs(xi - xf);
dy = abs(yi - yf);
if (dy > dx) {
swap(ξ, &yi);
swap(&xf, &yf);
swap(&dx, &dy);
slopegt1 = 1;
}
if (xi > xf) {
swap(ξ, &xf);
swap(&yi, &yf);
}
if (yi > yf)
incry = -1;
else
incry = 1;
d = 2 * dy - dx;
incre = 2 * dy;
incrne = 2 * (dy - dx);
while (xi < xf) {
if (d <= 0)
d += incre;
else {
d += incrne;
yi += incry;
}
xi++;
if (slopegt1)
paint_pixel(yi, xi, color);
else
paint_pixel(xi, yi, color);
}
return 0;
}
Link to comment
Share on other sites

olá, peço desculpa pela formatação anterior,

a linha 33 é

o return deste if:

if (sys_int86((r)) != OK) {
    printf("set_vbe_mode: sys_int86() failed \n");
    return 1;
}
a 98 é a linha da inplementação da função
paint_pixel(unsigned short x, unsigned short y, unsigned long color) {
Link to comment
Share on other sites

HappyHippyHippo

confirma que o código que colocaste aqui é o código que realmente estás a tentar compilar.

principalmente, o ficheiro que tem a alusão à função paint_pixel:

static unsigned bits_per_pixel; /* Number of VRAM bits per pixel */

int paint_pixel(unsigned short x, unsigned short y, unsigned long color); // <----------------------

void *vg_init(unsigned short mode) {
IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.