jonhhy Posted December 15, 2015 at 06:05 PM Report Share #590713 Posted December 15, 2015 at 06:05 PM 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(®86) != 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 More sharing options...
HappyHippyHippo Posted December 15, 2015 at 06:08 PM Report Share #590714 Posted December 15, 2015 at 06:08 PM qual é a linha 33 e a linha 98 ? e por favor usa as tags de código correctas IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
jonhhy Posted December 16, 2015 at 03:06 PM Author Report Share #590766 Posted December 16, 2015 at 03:06 PM 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 More sharing options...
HappyHippyHippo Posted December 16, 2015 at 03:18 PM Report Share #590767 Posted December 16, 2015 at 03:18 PM 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 Portugol Plus Link to comment Share on other sites More sharing options...
jonhhy Posted December 16, 2015 at 05:28 PM Author Report Share #590772 Posted December 16, 2015 at 05:28 PM sim tem razão, tinha duas pastas no eclipse com o mesmo ficheiro(video_gr.c) e push a declaração na pasta/projeto que não estava a ser compilado Obrigado! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now