I have a problem with making a program that uses winbgim.h header file. It is a simple program that makes just one simple circle. I am currently learning about winbgim and graphics.h libraries. I downloaded it, I downloaded the library and included it in Codeblocks following this and it works properly.
But when I try to use it, another code pops out and on the 302nd line it stands "error: redefinition of "int right". I am making this in a console file in Codeblocks IDE.
Can anyone help? Here is my code:
#include <iostream>
#include <winbgim.h>
#include <cstdlib>
using namespace std;
int main()
{
int gdriver = 9;
int gmode = 2;
initgraph(&gdriver,&gmode, "");
setbkcolor(WHITE);
setcolor(BLACK);
cleardevice();
circle(320,240,180);
getch();
closegraph();
return 0;
}
I don't know whether it suits this forum or not but I just wanted to tell (the world) something. I recently decided to try out WinBGIm library, so I downloaded the package and after setting up all the compiler and linker settings, ran my simple "Hello World" Code. But I got the following message from my compiler (MinGW, CodeBlocks IDE).
d:\codeblocks\mingw\bin..\lib\gcc\mingw32\4.4.1........\include\graphics.h|302|error: redefinition of 'int right'|
d:\codeblocks\mingw\bin..\lib\gcc\mingw32\4.4.1........\include\graphics.h|302|error: 'int right' previously declared here|
||=== Build finished: 2 errors, 0 warnings ===|
After having googled the problem I found out nothing (If you don't count a suggestion to use CodeBlocks-EP as a Solution). As I was taking a look at the header files, I found the problem (yeah!!!) The problem was with the function printimage. The original declaration was
//The original declaration. Note that there are two "right" variables
void printimage(
const char* title=NULL,
double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
bool active=true, HWND hwnd=NULL
);
So what I did is that, I simply changed one of the "right" (the later former one) variable to "top". That's it.
//The corrected code
void printimage(
const char* title=NULL,
double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
bool active=true, HWND hwnd=NULL
);